From 682d15fb97fa70095f1ff69a805d32d27b2261d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 04:27:43 +0000 Subject: [PATCH 001/138] Auto-generated commit be695e49537fa1d99270722645bec72c44cd07ac --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 372 +++++++ index.d.ts | 315 ++++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 43 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3934 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..88ba139 --- /dev/null +++ b/README.md @@ -0,0 +1,372 @@ + + +# Circular 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 circular array-like object. + + + +
+ +## Usage + +```javascript +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +``` + + + +#### circularArrayStream( src\[, options] ) + +Returns a [readable stream][readable-stream] from an array-like `object` which repeatedly iterates over a provided value's elements. + +```javascript +import inspectStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-inspect-sink@esm/index.mjs'; + +var iStream; +var stream; +var count; + +function log( chunk ) { + console.log( chunk.toString() ); + count += 1; + if ( count === 20 ) { + stream.destroy(); + } +} + +stream = circularArrayStream( [ 1, 2, 3, 4 ] ); +iStream = inspectStream( log ); + +count = 0; +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]. +- **iter**: number of iterations. Default: `1e308`. +- **dir**: iteration direction. If set to `-1`, the stream iterates over elements from right-to-left. Default: `1`. + +To set [stream][stream] `options`, + +```javascript +var opts = { + 'objectMode': true, + 'encoding': 'utf8', + 'highWaterMark': 64 +}; + +var stream = circularArrayStream( [ 1, 2, 3, 4 ], opts ); +``` + +By default, the returned [stream][stream] is an infinite stream (i.e., never ends). To limit the number of streamed values, set the `iter` 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 opts = { + 'iter': 10 +}; +var stream = circularArrayStream( [ 1, 2, 3, 4 ], opts ); +var iStream = inspectStream( log ); + +stream.pipe( iStream ); +``` + +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 = circularArrayStream( [ 1, 2, 3, 4 ], { + 'sep': ',', + 'iter': 10 +}); + +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 = circularArrayStream( [ 1, 2, 3, 4 ], { + 'serialize': serialize, + 'iter': 10 +}); + +var iStream = inspectStream( log ); + +stream.pipe( iStream ); +``` + +* * * + +#### circularArrayStream.factory( \[options] ) + +Returns a `function` for creating [readable streams][readable-stream] from array-like objects. + +```javascript +var opts = { + 'objectMode': true, + 'encoding': 'utf8', + 'highWaterMark': 64 +}; + +var createStream = circularArrayStream.factory( opts ); + +var stream1 = createStream( [ 1, 2, 3, 4 ] ); +var stream2 = createStream( [ 5, 6, 7, 8 ] ); +// ... +``` + +The method accepts the same `options` as [`circularArrayStream()`](#circular-array-stream). + +* * * + +#### circularArrayStream.objectMode( src\[, 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 opts = { + 'iter': 10 +}; +var stream = circularArrayStream.objectMode( [ 1, 2, 3, 4 ], opts ); + +opts = { + 'objectMode': true +}; +var iStream = inspectStream( opts, log ); + +stream.pipe( iStream ); +``` + +This method accepts the same `options` as [`circularArrayStream()`](#circular-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..ef3b255 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,315 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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; + + /** + * Number of iterations (default: `1e308`). + */ + iter?: number; + + /** + * Iteration direction (default: `1`). + */ + dir?: number; +} + +/** +* 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 which repeatedly iterates over a provided value's elements. + * + * @param src - source array-like object + * @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 + * @param options.iter - number of iterations (default: 1e308) + * @param options.dir - iteration direction (default: 1) + * @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 opts = { + * 'iter': arr.length * 2 + * }; + * + * var CircularArrayStream = circularArrayStream; + * var stream = new CircularArrayStream( arr, opts ); + * + * stream.pipe( inspectStream( log ) ); + */ + new( src: Collection, options?: Options ): Readable; // newable + + /** + * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. + * + * @param src - source array-like object + * @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 + * @param options.iter - number of iterations (default: 1e308) + * @param options.dir - iteration direction (default: 1) + * @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 opts = { + * 'iter': arr.length * 2 + * }; + * + * var stream = circularArrayStream( arr, opts ); + * + * stream.pipe( inspectStream( log ) ); + */ + ( src: Collection, options?: Options ): Readable; // callable + + /** + * Returns a function for creating readable streams from circular array-like objects. + * + * @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 + * @param options.iter - number of iterations (default: 1e308) + * @param options.dir - iteration direction (default: 1) + * @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 = circularArrayStream.factory( opts ); + * + * // Create 10 identically configured streams... + * var streams = []; + * for ( i = 0; i < 10; i++ ) { + * streams.push( createStream( arr ) ); + * } + */ + factory( options?: Options ): ( src: Collection ) => Readable; + + /** + * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. + * + * @param src - source array-like object + * @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 + * @param options.iter - number of iterations (default: 1e308) + * @param options.dir - iteration direction (default: 1) + * @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 opts = { + * 'iter': arr.length * 2 + * }; + * + * var stream = circularArrayStream.objectMode( arr, opts ); + * + * stream.pipe( inspectStream.objectMode( log ) ); + */ + objectMode( src: Collection, options?: Options ): Readable; +} + +/** +* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. +* +* @param src - source array-like object +* @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 opts = { +* 'iter': arr.length * 2 +* }; +* +* var CircularArrayStream = circularArrayStream; +* var stream = new CircularArrayStream( arr, opts ); +* +* 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 = circularArrayStream.factory( opts ); +* +* // Create 10 identically configured streams... +* var streams = []; +* for ( i = 0; i < 10; i++ ) { +* streams.push( createStream( arr ) ); +* } +* +* @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 opts = { +* 'iter': arr.length * 2 +* }; +* +* var stream = circularArrayStream.objectMode( arr, opts ); +* +* stream.pipe( inspectStream.objectMode( log ) ); +*/ +declare var circularArrayStream: Constructor; + + +// EXPORTS // + +export = circularArrayStream; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d305750 --- /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/utils-copy@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function j(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 v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function x(){throw new Error("clearTimeout has not been defined")}var y=_,w=x;function T(e){if(y===setTimeout)return setTimeout(e,0);if((y===_||!y)&&setTimeout)return y=setTimeout,setTimeout(e,0);try{return y(e,0)}catch(t){try{return y.call(null,e,0)}catch(t){return y.call(this,e,0)}}}"function"==typeof v.setTimeout&&(y=setTimeout),"function"==typeof v.clearTimeout&&(w=clearTimeout);var M,E=[],O=!1,z=-1;function k(){O&&M&&(O=!1,M.length?E=M.concat(E):z=-1,E.length&&P())}function P(){if(!O){var e=T(k);O=!0;for(var t=E.length;t;){for(M=E,E=[];++z1)for(var r=1;r1?new be(e,t):new be(e);if(!se(e))throw new TypeError(pe("invalid argument. First argument must be an array-like object. Value: `%s`.",e));if(r=ae(ce),arguments.length>1&&(i=fe(r,t)))throw i;return ge("Creating a readable stream configured with the following options: %s.",JSON.stringify(r)),ie.call(this,r),de(this,"_destroyed",!1),le(this,"_objectMode",r.objectMode),le(this,"_sep",r.sep),le(this,"_serialize",r.serialize||JSON.stringify),le(this,"_src",e),le(this,"_stride",r.dir),le(this,"_iter",r.iter),de(this,"_i",0),de(this,"_idx",1===r.dir?-1:e.length),this}n(be,ie),le(be.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return ge("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],ge("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?ue(r):ue(this._sep+r):oe(r)?this._i>1&&(r=he.concat([ue(this._sep),r])):t=new Error(pe("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),le(be.prototype,"destroy",(function(e){var t;return this._destroyed?(ge("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,me((function(){e&&(ge("Stream was destroyed due to an error. Error: %s.",ne(e)?e.message:JSON.stringify(e)),t.emit("error",e));ge("Closing the stream..."),t.emit("close")})),this)}));var je=h,ve=u,_e=s,xe=be;var ye=function(e,t){var r;if(arguments.length>1){if(!je(r=t))throw new TypeError(ve("invalid argument. Options argument must be an object. Value: `%s`.",r));r=_e(t,1)}else r={};return r.objectMode=!0,new xe(e,r)},we=s,Te=be;var Me=function(e){var t;return t=arguments.length?we(e,1):{},r;function r(e){return new Te(e,t)}},Ee=e,Oe=be,ze=ye,ke=Me;Ee(Oe,"objectMode",ze),Ee(Oe,"factory",ke);var Pe=Oe;export{Pe as default,ke as factory,ze as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a85c9de --- /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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","isNonNegativeInteger","require$$4","isString","require$$5","isFunction","require$$6","format","require$$7","validate_1","opts","options","sep","TypeError","objectMode","encoding","highWaterMark","serialize","iter","dir","type","debug_1","logger","isCollection","isError","isBuffer","copy","setNonEnumerable","setNonEnumerableReadOnly","string2buffer","require$$8","Buffer","require$$9","nextTick","require$$10","require$$11","DEFAULTS","require$$12","validate","require$$13","debug","require$$14","CircularArrayStream","src","err","this","arguments","length","JSON","stringify","call","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","_sep","concat","Error","emit","error","self","message","object_mode","factory_1","createStream","setReadOnly","stream","factory","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..d63c81e --- /dev/null +++ b/package.json @@ -0,0 +1,43 @@ +{ + "name": "@stdlib/streams-node-from-circular-array", + "version": "0.0.0", + "description": "Create a readable stream from a circular 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-circular-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", + "from", + "string", + "convert", + "to", + "circular", + "circ", + "repeat", + "infinite" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7c88ff3 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 92a31748d0767b7a6c0837b7f11cb4224f231bec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 23:12:19 +0000 Subject: [PATCH 002/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 e9f2fe72027a26488eec71fc3df0ff1571ff03d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 04:43:58 +0000 Subject: [PATCH 003/138] Remove files --- index.d.ts | 315 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3009 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d305750..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/utils-copy@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function j(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 v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function x(){throw new Error("clearTimeout has not been defined")}var y=_,w=x;function T(e){if(y===setTimeout)return setTimeout(e,0);if((y===_||!y)&&setTimeout)return y=setTimeout,setTimeout(e,0);try{return y(e,0)}catch(t){try{return y.call(null,e,0)}catch(t){return y.call(this,e,0)}}}"function"==typeof v.setTimeout&&(y=setTimeout),"function"==typeof v.clearTimeout&&(w=clearTimeout);var M,E=[],O=!1,z=-1;function k(){O&&M&&(O=!1,M.length?E=M.concat(E):z=-1,E.length&&P())}function P(){if(!O){var e=T(k);O=!0;for(var t=E.length;t;){for(M=E,E=[];++z1)for(var r=1;r1?new be(e,t):new be(e);if(!se(e))throw new TypeError(pe("invalid argument. First argument must be an array-like object. Value: `%s`.",e));if(r=ae(ce),arguments.length>1&&(i=fe(r,t)))throw i;return ge("Creating a readable stream configured with the following options: %s.",JSON.stringify(r)),ie.call(this,r),de(this,"_destroyed",!1),le(this,"_objectMode",r.objectMode),le(this,"_sep",r.sep),le(this,"_serialize",r.serialize||JSON.stringify),le(this,"_src",e),le(this,"_stride",r.dir),le(this,"_iter",r.iter),de(this,"_i",0),de(this,"_idx",1===r.dir?-1:e.length),this}n(be,ie),le(be.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return ge("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],ge("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?ue(r):ue(this._sep+r):oe(r)?this._i>1&&(r=he.concat([ue(this._sep),r])):t=new Error(pe("invalid operation. Serialization function must return a string or Buffer. Value: `%s`.",r))),t?this.emit("error",t):e=this.push(r)}})),le(be.prototype,"destroy",(function(e){var t;return this._destroyed?(ge("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,me((function(){e&&(ge("Stream was destroyed due to an error. Error: %s.",ne(e)?e.message:JSON.stringify(e)),t.emit("error",e));ge("Closing the stream..."),t.emit("close")})),this)}));var je=h,ve=u,_e=s,xe=be;var ye=function(e,t){var r;if(arguments.length>1){if(!je(r=t))throw new TypeError(ve("invalid argument. Options argument must be an object. Value: `%s`.",r));r=_e(t,1)}else r={};return r.objectMode=!0,new xe(e,r)},we=s,Te=be;var Me=function(e){var t;return t=arguments.length?we(e,1):{},r;function r(e){return new Te(e,t)}},Ee=e,Oe=be,ze=ye,ke=Me;Ee(Oe,"objectMode",ze),Ee(Oe,"factory",ke);var Pe=Oe;export{Pe as default,ke as factory,ze as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a85c9de..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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","isNonNegativeInteger","require$$4","isString","require$$5","isFunction","require$$6","format","require$$7","validate_1","opts","options","sep","TypeError","objectMode","encoding","highWaterMark","serialize","iter","dir","type","debug_1","logger","isCollection","isError","isBuffer","copy","setNonEnumerable","setNonEnumerableReadOnly","string2buffer","require$$8","Buffer","require$$9","nextTick","require$$10","require$$11","DEFAULTS","require$$12","validate","require$$13","debug","require$$14","CircularArrayStream","src","err","this","arguments","length","JSON","stringify","call","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","_sep","concat","Error","emit","error","self","message","object_mode","factory_1","createStream","setReadOnly","stream","factory","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 7c88ff3..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8c3dadc10d7cfc198007e7914e415c61e08a3f8a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 04:45:11 +0000 Subject: [PATCH 004/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 -- docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 192 -- test/test.js | 43 - test/test.main.js | 850 ------- test/test.object_mode.js | 194 -- test/test.validate.js | 302 --- 47 files changed, 2727 insertions(+), 5967 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 863c4be..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:07:33.406Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..b37e3ed --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bbfdbdb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1deab7c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..b7acb8c --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 e13e4829bb65c754029d32f92ff5defcc4027696 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 16:46:42 +0000 Subject: [PATCH 005/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 22680a643b6bfcfc35d0bb684fb8126dfaef57c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:43:10 +0000 Subject: [PATCH 006/138] Remove files --- index.d.ts | 315 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3009 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b37e3ed..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bbfdbdb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":";;u6HAyBIA,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,EAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,GAAaA,EAAUE,SACjBF,EAAUE,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,gFCqDtB,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,YAGtDJ,EAAY9S,EAAS,UACzB6S,EAAKM,KAAOnT,EAAQmT,MACdC,EAAsBP,EAAKM,OACzB,IAAIhQ,UAAW6P,EAAQ,QAAS,OAAQH,EAAKM,OAGjDL,EAAY9S,EAAS,SACzB6S,EAAKQ,IAAMrT,EAAQqT,IACD,IAAbR,EAAKQ,MAA2B,IAAdR,EAAKQ,KACpB,IAAIlQ,UAAW6P,EAAQ,QAAS,MAAOH,EAAKQ,MAG9C,KA5CC,IAAIlQ,UAAW6P,EAAQ,QAAShT,QClCrCN,UC4JJ,SAAS4T,GAAqB5L,EAAK1H,GAClC,IAAI6S,EACAvO,EACJ,KAAQnE,gBAAgBmT,IACvB,OAAKpJ,UAAUnL,OAAS,EAChB,IAAIuU,GAAqB5L,EAAK1H,GAE/B,IAAIsT,GAAqB5L,GAEjC,IAAM6L,EAAc7L,GACnB,MAAM,IAAIvE,UAAW6P,EAAQ,QAAStL,IAGvC,GADAmL,EAAOpM,EAAM+M,IACRtJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EAkCR,OA9BA5E,GAAO,wEAAyE+T,KAAKC,UAAWb,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBc,EAAkBxT,KAAM,cAAc,GAGtCyT,EAA0BzT,KAAM,cAAe0S,EAAKzS,YAGpDwT,EAA0BzT,KAAM,OAAQ0S,EAAKE,KAG7Ca,EAA0BzT,KAAM,aAAc0S,EAAKK,WAAaO,KAAKC,WAGrEE,EAA0BzT,KAAM,OAAQuH,GAGxCkM,EAA0BzT,KAAM,UAAW0S,EAAKQ,KAGhDO,EAA0BzT,KAAM,QAAS0S,EAAKM,MAG9CQ,EAAkBxT,KAAM,KAAM,GAG9BwT,EAAkBxT,KAAM,OAAuB,IAAb0S,EAAKQ,KAAe,EAAI3L,EAAI3I,QAEvDoB,KCtKR,SAASC,GAAYsH,EAAK1H,GACzB,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,IAAIkT,GAAqB5L,EAAKmL,GCbtC,SAASgB,GAAS7T,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAED8T,EAYP,SAASA,EAAcpM,GACtB,OAAO,IAAI4L,GAAqB5L,EAAKmL,IFyJvCkB,EAAST,GAAqBhV,EAAAA,QAAAA,UAY9BsV,EAA0BN,GAAoB/P,UAAW,SA3MzD,WAEC,IAAIyQ,EACA1P,EACAgN,EAEJ,IAAKnR,KAAK8T,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA1P,EAAM,KAENnE,KAAK+T,IAAM,EACN/T,KAAK+T,GAAK/T,KAAKgU,OAA8B,IAArBhU,KAAKiU,KAAKrV,OAEtC,OAAOoB,KAAK0C,KAAM,MAEnB1C,KAAKkU,MAAQlU,KAAKmU,QACbnU,KAAKmU,QAAU,GAAKnU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OAC/CoB,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OACZoB,KAAKmU,QAAU,GAAKnU,KAAKkU,KAAO,IAC3ClU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,QAExBuS,EAAInR,KAAKiU,KAAMjU,KAAKkU,MACpB3U,GAAO,gCAAiC+T,KAAKC,UAAWpC,GAAKnR,KAAKkU,KAAMlU,KAAK+T,KAEnD,IAArB/T,KAAKoU,cAES,iBADlBjD,EAAInR,KAAKqU,WAAYlD,IAGnBA,EADgB,IAAZnR,KAAK+T,GACLO,EAAenD,GAEfmD,EAAetU,KAAKuU,KAAKpD,GAEnBrO,EAAUqO,GAChBnR,KAAK+T,GAAK,IACd5C,EAAIrS,EAAO2G,OAAQ,CAAE6O,EAAetU,KAAKuU,MAAQpD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB0P,EAAM7T,KAAK0C,KAAMyO,OAwKpBsC,EAA0BN,GAAoB/P,UAAW,WA1JzD,SAAkBoR,GAEjB,IAAIrP,EACJ,OAAKnF,KAAK8T,aAIV3O,EAAOnF,KACPA,KAAK8T,YAAa,EAElBjP,GASA,WACM2P,IACJjV,GAAO,mDAAsD+Q,EAASkE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHrP,EAAKjC,KAAM,QAASsR,IAGrBrP,EAAKjC,KAAM,aApBJlD,QGFT0U,EAAA5U,GAAA,aAAAG,IACAyU,EAAA5U,GAAA,UAAA4T"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b7acb8c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b7d17a0fc0847415d547f355732d2cc3a03be2bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:43:59 +0000 Subject: [PATCH 007/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 -- docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 192 -- test/test.js | 43 - test/test.main.js | 850 ------- test/test.object_mode.js | 194 -- test/test.validate.js | 302 --- 47 files changed, 2727 insertions(+), 5967 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 47432f0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:11:44.675Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..b37e3ed --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bbfdbdb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1deab7c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..6a9074d --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 3e6c90aa1ffddafb1dade86b1e301d2e84b52b9a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:38:06 +0000 Subject: [PATCH 008/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 67a9e31ad0a4895acbe12d82c96ff3d3c2367407 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:07:28 +0000 Subject: [PATCH 009/138] Remove files --- index.d.ts | 315 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3009 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b37e3ed..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bbfdbdb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":";;u6HAyBIA,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,EAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,GAAaA,EAAUE,SACjBF,EAAUE,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,gFCqDtB,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,YAGtDJ,EAAY9S,EAAS,UACzB6S,EAAKM,KAAOnT,EAAQmT,MACdC,EAAsBP,EAAKM,OACzB,IAAIhQ,UAAW6P,EAAQ,QAAS,OAAQH,EAAKM,OAGjDL,EAAY9S,EAAS,SACzB6S,EAAKQ,IAAMrT,EAAQqT,IACD,IAAbR,EAAKQ,MAA2B,IAAdR,EAAKQ,KACpB,IAAIlQ,UAAW6P,EAAQ,QAAS,MAAOH,EAAKQ,MAG9C,KA5CC,IAAIlQ,UAAW6P,EAAQ,QAAShT,QClCrCN,UC4JJ,SAAS4T,GAAqB5L,EAAK1H,GAClC,IAAI6S,EACAvO,EACJ,KAAQnE,gBAAgBmT,IACvB,OAAKpJ,UAAUnL,OAAS,EAChB,IAAIuU,GAAqB5L,EAAK1H,GAE/B,IAAIsT,GAAqB5L,GAEjC,IAAM6L,EAAc7L,GACnB,MAAM,IAAIvE,UAAW6P,EAAQ,QAAStL,IAGvC,GADAmL,EAAOpM,EAAM+M,IACRtJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EAkCR,OA9BA5E,GAAO,wEAAyE+T,KAAKC,UAAWb,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBc,EAAkBxT,KAAM,cAAc,GAGtCyT,EAA0BzT,KAAM,cAAe0S,EAAKzS,YAGpDwT,EAA0BzT,KAAM,OAAQ0S,EAAKE,KAG7Ca,EAA0BzT,KAAM,aAAc0S,EAAKK,WAAaO,KAAKC,WAGrEE,EAA0BzT,KAAM,OAAQuH,GAGxCkM,EAA0BzT,KAAM,UAAW0S,EAAKQ,KAGhDO,EAA0BzT,KAAM,QAAS0S,EAAKM,MAG9CQ,EAAkBxT,KAAM,KAAM,GAG9BwT,EAAkBxT,KAAM,OAAuB,IAAb0S,EAAKQ,KAAe,EAAI3L,EAAI3I,QAEvDoB,KCtKR,SAASC,GAAYsH,EAAK1H,GACzB,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,IAAIkT,GAAqB5L,EAAKmL,GCbtC,SAASgB,GAAS7T,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAED8T,EAYP,SAASA,EAAcpM,GACtB,OAAO,IAAI4L,GAAqB5L,EAAKmL,IFyJvCkB,EAAST,GAAqBhV,EAAAA,QAAAA,UAY9BsV,EAA0BN,GAAoB/P,UAAW,SA3MzD,WAEC,IAAIyQ,EACA1P,EACAgN,EAEJ,IAAKnR,KAAK8T,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA1P,EAAM,KAENnE,KAAK+T,IAAM,EACN/T,KAAK+T,GAAK/T,KAAKgU,OAA8B,IAArBhU,KAAKiU,KAAKrV,OAEtC,OAAOoB,KAAK0C,KAAM,MAEnB1C,KAAKkU,MAAQlU,KAAKmU,QACbnU,KAAKmU,QAAU,GAAKnU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OAC/CoB,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OACZoB,KAAKmU,QAAU,GAAKnU,KAAKkU,KAAO,IAC3ClU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,QAExBuS,EAAInR,KAAKiU,KAAMjU,KAAKkU,MACpB3U,GAAO,gCAAiC+T,KAAKC,UAAWpC,GAAKnR,KAAKkU,KAAMlU,KAAK+T,KAEnD,IAArB/T,KAAKoU,cAES,iBADlBjD,EAAInR,KAAKqU,WAAYlD,IAGnBA,EADgB,IAAZnR,KAAK+T,GACLO,EAAenD,GAEfmD,EAAetU,KAAKuU,KAAKpD,GAEnBrO,EAAUqO,GAChBnR,KAAK+T,GAAK,IACd5C,EAAIrS,EAAO2G,OAAQ,CAAE6O,EAAetU,KAAKuU,MAAQpD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB0P,EAAM7T,KAAK0C,KAAMyO,OAwKpBsC,EAA0BN,GAAoB/P,UAAW,WA1JzD,SAAkBoR,GAEjB,IAAIrP,EACJ,OAAKnF,KAAK8T,aAIV3O,EAAOnF,KACPA,KAAK8T,YAAa,EAElBjP,GASA,WACM2P,IACJjV,GAAO,mDAAsD+Q,EAASkE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHrP,EAAKjC,KAAM,QAASsR,IAGrBrP,EAAKjC,KAAM,aApBJlD,QGFT0U,EAAA5U,GAAA,aAAAG,IACAyU,EAAA5U,GAAA,UAAA4T"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6a9074d..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From daed96f077e6b5f4688732247ac495cd5c35cca9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:08:29 +0000 Subject: [PATCH 010/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 -- docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 192 -- test/test.js | 43 - test/test.main.js | 850 ------- test/test.object_mode.js | 194 -- test/test.validate.js | 302 --- 46 files changed, 2727 insertions(+), 5932 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 14dba89..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-circular-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 80c47eb..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-circular-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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..b37e3ed --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bbfdbdb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1deab7c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..a99dc4f --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 0e1207e37147d910626b898d128110358e7e735c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:51:54 +0000 Subject: [PATCH 011/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 5f6d0daf61ddf257e7fe77c6c6e0729e7efafdf8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 11:15:32 +0000 Subject: [PATCH 012/138] Remove files --- index.d.ts | 315 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3009 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b37e3ed..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bbfdbdb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":";;u6HAyBIA,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,EAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,GAAaA,EAAUE,SACjBF,EAAUE,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,gFCqDtB,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,YAGtDJ,EAAY9S,EAAS,UACzB6S,EAAKM,KAAOnT,EAAQmT,MACdC,EAAsBP,EAAKM,OACzB,IAAIhQ,UAAW6P,EAAQ,QAAS,OAAQH,EAAKM,OAGjDL,EAAY9S,EAAS,SACzB6S,EAAKQ,IAAMrT,EAAQqT,IACD,IAAbR,EAAKQ,MAA2B,IAAdR,EAAKQ,KACpB,IAAIlQ,UAAW6P,EAAQ,QAAS,MAAOH,EAAKQ,MAG9C,KA5CC,IAAIlQ,UAAW6P,EAAQ,QAAShT,QClCrCN,UC4JJ,SAAS4T,GAAqB5L,EAAK1H,GAClC,IAAI6S,EACAvO,EACJ,KAAQnE,gBAAgBmT,IACvB,OAAKpJ,UAAUnL,OAAS,EAChB,IAAIuU,GAAqB5L,EAAK1H,GAE/B,IAAIsT,GAAqB5L,GAEjC,IAAM6L,EAAc7L,GACnB,MAAM,IAAIvE,UAAW6P,EAAQ,QAAStL,IAGvC,GADAmL,EAAOpM,EAAM+M,IACRtJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EAkCR,OA9BA5E,GAAO,wEAAyE+T,KAAKC,UAAWb,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBc,EAAkBxT,KAAM,cAAc,GAGtCyT,EAA0BzT,KAAM,cAAe0S,EAAKzS,YAGpDwT,EAA0BzT,KAAM,OAAQ0S,EAAKE,KAG7Ca,EAA0BzT,KAAM,aAAc0S,EAAKK,WAAaO,KAAKC,WAGrEE,EAA0BzT,KAAM,OAAQuH,GAGxCkM,EAA0BzT,KAAM,UAAW0S,EAAKQ,KAGhDO,EAA0BzT,KAAM,QAAS0S,EAAKM,MAG9CQ,EAAkBxT,KAAM,KAAM,GAG9BwT,EAAkBxT,KAAM,OAAuB,IAAb0S,EAAKQ,KAAe,EAAI3L,EAAI3I,QAEvDoB,KCtKR,SAASC,GAAYsH,EAAK1H,GACzB,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,IAAIkT,GAAqB5L,EAAKmL,GCbtC,SAASgB,GAAS7T,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAED8T,EAYP,SAASA,EAAcpM,GACtB,OAAO,IAAI4L,GAAqB5L,EAAKmL,IFyJvCkB,EAAST,GAAqBhV,EAAAA,QAAAA,UAY9BsV,EAA0BN,GAAoB/P,UAAW,SA3MzD,WAEC,IAAIyQ,EACA1P,EACAgN,EAEJ,IAAKnR,KAAK8T,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA1P,EAAM,KAENnE,KAAK+T,IAAM,EACN/T,KAAK+T,GAAK/T,KAAKgU,OAA8B,IAArBhU,KAAKiU,KAAKrV,OAEtC,OAAOoB,KAAK0C,KAAM,MAEnB1C,KAAKkU,MAAQlU,KAAKmU,QACbnU,KAAKmU,QAAU,GAAKnU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OAC/CoB,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OACZoB,KAAKmU,QAAU,GAAKnU,KAAKkU,KAAO,IAC3ClU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,QAExBuS,EAAInR,KAAKiU,KAAMjU,KAAKkU,MACpB3U,GAAO,gCAAiC+T,KAAKC,UAAWpC,GAAKnR,KAAKkU,KAAMlU,KAAK+T,KAEnD,IAArB/T,KAAKoU,cAES,iBADlBjD,EAAInR,KAAKqU,WAAYlD,IAGnBA,EADgB,IAAZnR,KAAK+T,GACLO,EAAenD,GAEfmD,EAAetU,KAAKuU,KAAKpD,GAEnBrO,EAAUqO,GAChBnR,KAAK+T,GAAK,IACd5C,EAAIrS,EAAO2G,OAAQ,CAAE6O,EAAetU,KAAKuU,MAAQpD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB0P,EAAM7T,KAAK0C,KAAMyO,OAwKpBsC,EAA0BN,GAAoB/P,UAAW,WA1JzD,SAAkBoR,GAEjB,IAAIrP,EACJ,OAAKnF,KAAK8T,aAIV3O,EAAOnF,KACPA,KAAK8T,YAAa,EAElBjP,GASA,WACM2P,IACJjV,GAAO,mDAAsD+Q,EAASkE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHrP,EAAKjC,KAAM,QAASsR,IAGrBrP,EAAKjC,KAAM,aApBJlD,QGFT0U,EAAA5U,GAAA,aAAAG,IACAyU,EAAA5U,GAAA,UAAA4T"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a99dc4f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 679d27c99709a3f1433d06e388f6430e392e0e9a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 11:16:30 +0000 Subject: [PATCH 013/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 -- docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 192 -- test/test.js | 43 - test/test.main.js | 850 ------- test/test.object_mode.js | 194 -- test/test.validate.js | 302 --- 47 files changed, 2727 insertions(+), 6006 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 0222151..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:14:53.913Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..9d820ad --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2b42691 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1deab7c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..cb82be4 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 ddcd1879ae869620f67fe101273fdf0d20e495f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:32:40 +0000 Subject: [PATCH 014/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 2dba2830f299a5df548d6574c735df9f1de98b02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:41:53 +0000 Subject: [PATCH 015/138] Remove files --- index.d.ts | 315 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3009 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d820ad..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2b42691..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 cb82be4..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From bbcdc8512e2d3923ca8d86a78ba3799ba616df7a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:42:52 +0000 Subject: [PATCH 016/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 -- docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 192 -- test/test.js | 43 - test/test.main.js | 850 ------- test/test.object_mode.js | 194 -- test/test.validate.js | 302 --- 47 files changed, 2727 insertions(+), 6022 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 9345669..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:12:50.834Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..9d820ad --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2b42691 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1deab7c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..d1fc9c1 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 dbe9c05c7f83fe3ca92ab0add8e54aabcf5394c9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 01:38:25 +0000 Subject: [PATCH 017/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 72109af29ce6eecdedf3b168e653d3fc29336878 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 18:10:39 +0000 Subject: [PATCH 018/138] Remove files --- index.d.ts | 315 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3009 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d820ad..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2b42691..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly"],"mappings":";;86HAyBIA,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,EAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,GAAaA,EAAUE,SACjBF,EAAUE,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,gFCqDtB,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,YAGtDJ,EAAY9S,EAAS,UACzB6S,EAAKM,KAAOnT,EAAQmT,MACdC,EAAsBP,EAAKM,OACzB,IAAIhQ,UAAW6P,EAAQ,QAAS,OAAQH,EAAKM,OAGjDL,EAAY9S,EAAS,SACzB6S,EAAKQ,IAAMrT,EAAQqT,IACD,IAAbR,EAAKQ,MAA2B,IAAdR,EAAKQ,KACpB,IAAIlQ,UAAW6P,EAAQ,QAAS,MAAOH,EAAKQ,MAG9C,KA5CC,IAAIlQ,UAAW6P,EAAQ,QAAShT,QClCrCN,UC4JJ,SAAS4T,GAAqB5L,EAAK1H,GAClC,IAAI6S,EACAvO,EACJ,KAAQnE,gBAAgBmT,IACvB,OAAKpJ,UAAUnL,OAAS,EAChB,IAAIuU,GAAqB5L,EAAK1H,GAE/B,IAAIsT,GAAqB5L,GAEjC,IAAM6L,EAAc7L,GACnB,MAAM,IAAIvE,UAAW6P,EAAQ,QAAStL,IAGvC,GADAmL,EAAOpM,EAAM+M,IACRtJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EAkCR,OA9BA5E,GAAO,wEAAyE+T,KAAKC,UAAWb,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBc,EAAkBxT,KAAM,cAAc,GAGtCyT,EAA0BzT,KAAM,cAAe0S,EAAKzS,YAGpDwT,EAA0BzT,KAAM,OAAQ0S,EAAKE,KAG7Ca,EAA0BzT,KAAM,aAAc0S,EAAKK,WAAaO,KAAKC,WAGrEE,EAA0BzT,KAAM,OAAQuH,GAGxCkM,EAA0BzT,KAAM,UAAW0S,EAAKQ,KAGhDO,EAA0BzT,KAAM,QAAS0S,EAAKM,MAG9CQ,EAAkBxT,KAAM,KAAM,GAG9BwT,EAAkBxT,KAAM,OAAuB,IAAb0S,EAAKQ,KAAe,EAAI3L,EAAI3I,QAEvDoB,KCtKR,SAASC,GAAYsH,EAAK1H,GACzB,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,IAAIkT,GAAqB5L,EAAKmL,GCbtC,SAASgB,GAAS7T,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAED8T,EAYP,SAASA,EAAcpM,GACtB,OAAO,IAAI4L,GAAqB5L,EAAKmL,IFyJvCkB,EAAST,GAAqBhV,EAAAA,QAAAA,UAY9BsV,EAA0BN,GAAoB/P,UAAW,SA3MzD,WAEC,IAAIyQ,EACA1P,EACAgN,EAEJ,IAAKnR,KAAK8T,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA1P,EAAM,KAENnE,KAAK+T,IAAM,EACN/T,KAAK+T,GAAK/T,KAAKgU,OAA8B,IAArBhU,KAAKiU,KAAKrV,OAEtC,OAAOoB,KAAK0C,KAAM,MAEnB1C,KAAKkU,MAAQlU,KAAKmU,QACbnU,KAAKmU,QAAU,GAAKnU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OAC/CoB,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OACZoB,KAAKmU,QAAU,GAAKnU,KAAKkU,KAAO,IAC3ClU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,QAExBuS,EAAInR,KAAKiU,KAAMjU,KAAKkU,MACpB3U,GAAO,gCAAiC+T,KAAKC,UAAWpC,GAAKnR,KAAKkU,KAAMlU,KAAK+T,KAEnD,IAArB/T,KAAKoU,cAES,iBADlBjD,EAAInR,KAAKqU,WAAYlD,IAGnBA,EADgB,IAAZnR,KAAK+T,GACLO,EAAenD,GAEfmD,EAAetU,KAAKuU,KAAKpD,GAEnBrO,EAAUqO,GAChBnR,KAAK+T,GAAK,IACd5C,EAAIrS,EAAO2G,OAAQ,CAAE6O,EAAetU,KAAKuU,MAAQpD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB0P,EAAM7T,KAAK0C,KAAMyO,OAwKpBsC,EAA0BN,GAAoB/P,UAAW,WA1JzD,SAAkBoR,GAEjB,IAAIrP,EACJ,OAAKnF,KAAK8T,aAIV3O,EAAOnF,KACPA,KAAK8T,YAAa,EAElBjP,GASA,WACM2P,IACJjV,GAAO,mDAAsD+Q,EAASkE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHrP,EAAKjC,KAAM,QAASsR,IAGrBrP,EAAKjC,KAAM,aApBJlD,QGFT0U,EAAA5U,GAAA,aAAAG,IACAyU,EAAA5U,GAAA,UAAA4T"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d1fc9c1..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a6c56fe4ac6aeb7b0db93efc26f30212c7fdba12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 18:11:35 +0000 Subject: [PATCH 019/138] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 -- docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 192 -- test/test.js | 43 - test/test.main.js | 850 ------- test/test.object_mode.js | 194 -- test/test.validate.js | 302 --- 47 files changed, 2727 insertions(+), 6022 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 e434a19..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:37:49.495Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..9d820ad --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ffa499b --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","error","message","setReadOnly","main"],"mappings":";;86HAyBIA,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,EAAYtB,QAAQ,QACpBuB,QAAQ,EAEVA,GADED,GAAaA,EAAUE,SACjBF,EAAUE,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,gFCqDtB,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,YAGtDJ,EAAY9S,EAAS,UACzB6S,EAAKM,KAAOnT,EAAQmT,MACdC,EAAsBP,EAAKM,OACzB,IAAIhQ,UAAW6P,EAAQ,QAAS,OAAQH,EAAKM,OAGjDL,EAAY9S,EAAS,SACzB6S,EAAKQ,IAAMrT,EAAQqT,IACD,IAAbR,EAAKQ,MAA2B,IAAdR,EAAKQ,KACpB,IAAIlQ,UAAW6P,EAAQ,QAAS,MAAOH,EAAKQ,MAG9C,KA5CC,IAAIlQ,UAAW6P,EAAQ,QAAShT,QClCrCN,UC4JJ,SAAS4T,GAAqB5L,EAAK1H,GAClC,IAAI6S,EACAvO,EACJ,KAAQnE,gBAAgBmT,IACvB,OAAKpJ,UAAUnL,OAAS,EAChB,IAAIuU,GAAqB5L,EAAK1H,GAE/B,IAAIsT,GAAqB5L,GAEjC,IAAM6L,EAAc7L,GACnB,MAAM,IAAIvE,UAAW6P,EAAQ,QAAStL,IAGvC,GADAmL,EAAOpM,EAAM+M,IACRtJ,UAAUnL,OAAS,IACvBuF,EAAMsO,GAAUC,EAAM7S,IAErB,MAAMsE,EAkCR,OA9BA5E,GAAO,wEAAyE+T,KAAKC,UAAWb,IAChGvU,EAAAA,QAAAA,SAAS+D,KAAMlC,KAAM0S,GAGrBc,EAAkBxT,KAAM,cAAc,GAGtCyT,EAA0BzT,KAAM,cAAe0S,EAAKzS,YAGpDwT,EAA0BzT,KAAM,OAAQ0S,EAAKE,KAG7Ca,EAA0BzT,KAAM,aAAc0S,EAAKK,WAAaO,KAAKC,WAGrEE,EAA0BzT,KAAM,OAAQuH,GAGxCkM,EAA0BzT,KAAM,UAAW0S,EAAKQ,KAGhDO,EAA0BzT,KAAM,QAAS0S,EAAKM,MAG9CQ,EAAkBxT,KAAM,KAAM,GAG9BwT,EAAkBxT,KAAM,OAAuB,IAAb0S,EAAKQ,KAAe,EAAI3L,EAAI3I,QAEvDoB,KCtKR,SAASC,GAAYsH,EAAK1H,GACzB,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,IAAIkT,GAAqB5L,EAAKmL,GCbtC,SAASgB,GAAS7T,GACjB,IAAI6S,EAMJ,OAJCA,EADI3I,UAAUnL,OACP0H,EAAMzG,EAAS,GAEf,GAED8T,EAYP,SAASA,EAAcpM,GACtB,OAAO,IAAI4L,GAAqB5L,EAAKmL,IFyJvCkB,EAAST,GAAqBhV,EAAAA,QAAAA,UAY9BsV,EAA0BN,GAAoB/P,UAAW,SA3MzD,WAEC,IAAIyQ,EACA1P,EACAgN,EAEJ,IAAKnR,KAAK8T,WAIV,IADAD,GAAM,EACEA,GAAM,CAIb,GAHA1P,EAAM,KAENnE,KAAK+T,IAAM,EACN/T,KAAK+T,GAAK/T,KAAKgU,OAA8B,IAArBhU,KAAKiU,KAAKrV,OAEtC,OAAOoB,KAAK0C,KAAM,MAEnB1C,KAAKkU,MAAQlU,KAAKmU,QACbnU,KAAKmU,QAAU,GAAKnU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OAC/CoB,KAAKkU,MAAQlU,KAAKiU,KAAKrV,OACZoB,KAAKmU,QAAU,GAAKnU,KAAKkU,KAAO,IAC3ClU,KAAKkU,MAAQlU,KAAKiU,KAAKrV,QAExBuS,EAAInR,KAAKiU,KAAMjU,KAAKkU,MACpB3U,GAAO,gCAAiC+T,KAAKC,UAAWpC,GAAKnR,KAAKkU,KAAMlU,KAAK+T,KAEnD,IAArB/T,KAAKoU,cAES,iBADlBjD,EAAInR,KAAKqU,WAAYlD,IAGnBA,EADgB,IAAZnR,KAAK+T,GACLO,EAAenD,GAEfmD,EAAetU,KAAKuU,KAAKpD,GAEnBrO,EAAUqO,GAChBnR,KAAK+T,GAAK,IACd5C,EAAIrS,EAAO2G,OAAQ,CAAE6O,EAAetU,KAAKuU,MAAQpD,KAGlDhN,EAAM,IAAIZ,MAAOsP,EAAQ,QAAS1B,KAG/BhN,EACJnE,KAAKkD,KAAM,QAASiB,GAEpB0P,EAAM7T,KAAK0C,KAAMyO,OAwKpBsC,EAA0BN,GAAoB/P,UAAW,WA1JzD,SAAkBoR,GAEjB,IAAIrP,EACJ,OAAKnF,KAAK8T,aAIV3O,EAAOnF,KACPA,KAAK8T,YAAa,EAElBjP,GASA,WACM2P,IACJjV,GAAO,mDAAsD+Q,EAASkE,GAAYA,EAAMC,QAAUnB,KAAKC,UAAWiB,IAClHrP,EAAKjC,KAAM,QAASsR,IAGrBrP,EAAKjC,KAAM,aApBJlD,QGFT0U,EAAAC,GAAA,aAAA1U,IACAyU,EAAAC,GAAA,UAAAjB"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..840fbe7 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 86250e7dcf291956116b4b90af9b99a7c5db70f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 03:44:28 +0000 Subject: [PATCH 020/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 d9216b88ece8a9148e68688ae3c5049de4d8f16f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 17:38:45 +0000 Subject: [PATCH 021/138] Remove files --- index.d.ts | 315 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 3009 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d820ad..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ffa499b..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 840fbe7..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 374b6ae47f891ca114fb95b2894c3ede182b891d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 17:39:39 +0000 Subject: [PATCH 022/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ----- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 47 files changed, 4082 insertions(+), 6022 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 47a5956..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:25:59.296Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..9d820ad --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..36b58da --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..87586bf --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 886f443523ed52dd86c823e177a0dc7f2a40244f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:12:00 +0000 Subject: [PATCH 023/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index d704d7a..2aaadb6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 d7d1334a2a4d690f1c426e286f692cf4d038ac0e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 07:49:57 +0000 Subject: [PATCH 024/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4364 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9d820ad..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 f from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";function w(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 m={exports:{}},v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function _(){throw new Error("setTimeout has not been defined")}function E(){throw new Error("clearTimeout has not been defined")}var R=_,S=E;function j(e){if(R===setTimeout)return setTimeout(e,0);if((R===_||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(t){return R.call(this,e,0)}}}"function"==typeof v.setTimeout&&(R=setTimeout),"function"==typeof v.clearTimeout&&(S=clearTimeout);var T,k=[],x=!1,M=-1;function A(){x&&T&&(x=!1,T.length?k=T.concat(k):M=-1,k.length&&P())}function P(){if(!x){var e=j(A);x=!0;for(var t=k.length;t;){for(T=k,k=[];++M1)for(var r=1;r0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===G.prototype||(t=function(e){return G.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):ue(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?ue(e,s,t,!1):ce(e,s)):ue(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 he(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(ee("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?H.nextTick(le,e):le(e))}function le(e){ee("emit readable"),e.emit("readable"),ye(e)}function ce(e,t){t.readingMore||(t.readingMore=!0,H.nextTick(de,e,t))}function de(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=G.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 we(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,H.nextTick(me,t,e))}function me(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function ve(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return ee("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?we(this):he(this),null;if(0===(e=fe(e,t))&&t.ended)return 0===t.length&&we(this),null;var n,i=t.needReadable;return ee("need readable",i),(0===t.length||t.length-e0?be(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&we(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},se.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,ee("pipe count=%d opts=%j",n.pipesCount,t);var i=(!t||!1!==t.end)&&e!==F.stdout&&e!==F.stderr?s:p;function o(t,i){ee("onunpipe"),t===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,ee("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(){ee("onend"),e.end()}n.endEmitted?H.nextTick(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;ee("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&X(e,"data")&&(t.flowing=!0,ye(e))}}(r);e.on("drain",a);var u=!1;var f=!1;function h(t){ee("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==ve(n.pipes,e))&&!u&&(ee("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function l(t){ee("onerror",t),p(),e.removeListener("error",l),0===X(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",d),p()}function d(){ee("onfinish"),e.removeListener("close",c),p()}function p(){ee("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]?V(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||(ee("pipe resume"),r.resume()),e},se.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:Ee.nextTick;Ce.WritableState=Ue;var Te=Object.create(require("core-util-is"));Te.inherits=require("inherits");var ke={deprecate:require("util-deprecate")},xe=require("./internal/streams/stream"),Me=require("safe-buffer").Buffer,Ae=v.Uint8Array||function(){};var Pe,Oe=require("./internal/streams/destroy");function Be(){}function Ue(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?(Ee.nextTick(i,n),Ee.nextTick(We,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),We(e,t))}(e,r,n,t,i);else{var o=Ie(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||qe(e,r),n?je(De,e,r,o,i):De(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 Re(this)}function Ce(e){if(Se=Se||require("./_stream_duplex"),!(Pe.call(Ce,this)||this instanceof Se))return new Ce(e);this._writableState=new Ue(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 Le(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 De(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),We(e,t)}function qe(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,Le(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 Re(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(Le(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 Ie(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Ye(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),We(e,t)}))}function We(e,t){var r=Ie(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,Ee.nextTick(Ye,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}Te.inherits(Ce,xe),Ue.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ue.prototype,"buffer",{get:ke.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]?(Pe=Function.prototype[Symbol.hasInstance],Object.defineProperty(Ce,Symbol.hasInstance,{value:function(e){return!!Pe.call(this,e)||this===Ce&&(e&&e._writableState instanceof Ue)}})):Pe=function(e){return e instanceof this},Ce.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Ce.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,Me.isBuffer(n)||n instanceof Ae);return s&&!Me.isBuffer(e)&&(e=function(e){return Me.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=Be),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),Ee.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),Ee.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=Me.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(Ce.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Ce.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Ce.prototype._writev=null,Ce.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,We(e,t),r&&(t.finished?Ee.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(Ce.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Ce.prototype.destroy=Oe.destroy,Ce.prototype._undestroy=Oe.undestroy,Ce.prototype._destroy=function(e,t){this.end(),t(e)};var ze=w(Object.freeze({__proto__:null}));void 0===F||!F.version||0===F.version.indexOf("v0.")||0===F.version.indexOf("v1.")&&0!==F.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 F.nextTick(e);case 2:return F.nextTick((function(){e.call(null,t)}));case 3:return F.nextTick((function(){e.call(null,t,r)}));case 4:return F.nextTick((function(){e.call(null,t,r,n)}));default:for(i=new Array(s-1),o=0;o>18&63]+He[i>>12&63]+He[i>>6&63]+He[63&i]);return o.join("")}function Ke(e){var t;Xe||Ze();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+=He[t>>2],i+=He[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=He[t>>10],i+=He[t>>4&63],i+=He[t<<2&63],i+="="),o.push(i),o.join("")}function Qe(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 $e(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 et={}.toString,tt=Array.isArray||function(e){return"[object Array]"==et.call(e)};ot.TYPED_ARRAY_SUPPORT=void 0===v.TYPED_ARRAY_SUPPORT||v.TYPED_ARRAY_SUPPORT;var rt=nt();function nt(){return ot.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function it(e,t){if(nt()=nt())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+nt().toString(16)+" bytes");return 0|e}function lt(e){return!(null==e||!e._isBuffer)}function ct(e,t){if(lt(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 qt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(e).length;default:if(n)return qt(e).length;t=(""+t).toLowerCase(),n=!0}}function dt(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 kt(this,t,r);case"utf8":case"utf-8":return St(this,t,r);case"ascii":return jt(this,t,r);case"latin1":case"binary":return Tt(this,t,r);case"base64":return Rt(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 pt(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function gt(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=ot.from(t,n)),lt(t))return 0===t.length?-1:yt(e,t,r,n,i);if("number"==typeof t)return t&=255,ot.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):yt(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yt(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 Rt(e,t,r){return 0===t&&r===e.length?Ke(e):Ke(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+=" ... ")),""},ot.prototype.compare=function(e,t,r,n,i){if(!lt(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 bt(this,e,t,r);case"utf8":case"utf-8":return wt(this,e,t,r);case"ascii":return mt(this,e,t,r);case"latin1":case"binary":return vt(this,e,t,r);case"base64":return _t(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},ot.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(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 At(e,t,r,n,i,o){if(!lt(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Pt(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 Ot(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 Bt(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 Ut(e,t,r,n,i){return i||Bt(e,0,r,4),$e(e,t,r,n,23,4),r+4}function Ct(e,t,r,n,i){return i||Bt(e,0,r,8),$e(e,t,r,n,52,8),r+8}ot.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},ot.prototype.readUInt8=function(e,t){return t||Mt(e,1,this.length),this[e]},ot.prototype.readUInt16LE=function(e,t){return t||Mt(e,2,this.length),this[e]|this[e+1]<<8},ot.prototype.readUInt16BE=function(e,t){return t||Mt(e,2,this.length),this[e]<<8|this[e+1]},ot.prototype.readUInt32LE=function(e,t){return t||Mt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},ot.prototype.readUInt32BE=function(e,t){return t||Mt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},ot.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||Mt(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},ot.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||Mt(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},ot.prototype.readInt8=function(e,t){return t||Mt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},ot.prototype.readInt16LE=function(e,t){t||Mt(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt16BE=function(e,t){t||Mt(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},ot.prototype.readInt32LE=function(e,t){return t||Mt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},ot.prototype.readInt32BE=function(e,t){return t||Mt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},ot.prototype.readFloatLE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!0,23,4)},ot.prototype.readFloatBE=function(e,t){return t||Mt(e,4,this.length),Qe(this,e,!1,23,4)},ot.prototype.readDoubleLE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!0,52,8)},ot.prototype.readDoubleBE=function(e,t){return t||Mt(e,8,this.length),Qe(this,e,!1,52,8)},ot.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||At(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},ot.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,255,0),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},ot.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,65535,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ot(this,e,t,!0),t+4},ot.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,4294967295,0),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);At(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},ot.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,1,127,-128),ot.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},ot.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Pt(this,e,t,!0),t+2},ot.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,2,32767,-32768),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Pt(this,e,t,!1),t+2},ot.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),ot.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ot(this,e,t,!0),t+4},ot.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||At(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ot.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ot(this,e,t,!1),t+4},ot.prototype.writeFloatLE=function(e,t,r){return Ut(this,e,t,!0,r)},ot.prototype.writeFloatBE=function(e,t,r){return Ut(this,e,t,!1,r)},ot.prototype.writeDoubleLE=function(e,t,r){return Ct(this,e,t,!0,r)},ot.prototype.writeDoubleBE=function(e,t,r){return Ct(this,e,t,!1,r)},ot.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||!ot.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 It(e){return function(e){var t,r,n,i,o,s;Xe||Ze();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 Ve(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=Je[e.charCodeAt(t)]<<2|Je[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=Je[e.charCodeAt(t)]<<10|Je[e.charCodeAt(t+1)]<<4|Je[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(Lt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wt(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 Nt=w(Object.freeze({__proto__:null,Buffer:ot,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),ot.alloc(+e)},isBuffer:Wt,kMaxLength:rt}));function Ft(e){return Object.prototype.toString.call(e)}Fe.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===Ft(e)},Fe.isBoolean=function(e){return"boolean"==typeof e},Fe.isNull=function(e){return null===e},Fe.isNullOrUndefined=function(e){return null==e},Fe.isNumber=function(e){return"number"==typeof e},Fe.isString=function(e){return"string"==typeof e},Fe.isSymbol=function(e){return"symbol"==typeof e},Fe.isUndefined=function(e){return void 0===e},Fe.isRegExp=function(e){return"[object RegExp]"===Ft(e)},Fe.isObject=function(e){return"object"==typeof e&&null!==e},Fe.isDate=function(e){return"[object Date]"===Ft(e)},Fe.isError=function(e){return"[object Error]"===Ft(e)||e instanceof Error},Fe.isFunction=function(e){return"function"==typeof e},Fe.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},Fe.isBuffer=Nt.Buffer.isBuffer;var Ht="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},Jt=w(Object.freeze({__proto__:null,default:Ht})),Vt=Ne,Xt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},Zt=rr,Gt=Object.create(Fe);Gt.inherits=Jt;var Kt=_e,Qt=ze;Gt.inherits(rr,Kt);for(var $t=Xt(Qt.prototype),er=0;er<$t.length;er++){var tr=$t[er];rr.prototype[tr]||(rr.prototype[tr]=Qt.prototype[tr])}function rr(e){if(!(this instanceof rr))return new rr(e);Kt.call(this,e),Qt.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",nr)}function nr(){this.allowHalfOpen||this._writableState.ended||Vt.nextTick(ir,this)}function ir(e){e.end()}Object.defineProperty(rr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(rr.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),rr.prototype._destroy=function(e,t){this.push(null),this.end(),Vt.nextTick(t,e)};var or=fr,sr=Zt,ar=Object.create(Fe);function ur(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{};function mr(r,n){var o,a;if(!(this instanceof mr))return arguments.length>1?new mr(r,n):new mr(r);if(!t(r))throw new TypeError(h("0fz2a",r));if(o=i(yr),arguments.length>1&&(a=br(o,n)))throw a;return wr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),m.exports.Readable.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(h("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new mr(e,r)}function _r(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new mr(e,t)}}o(mr,m.exports.Readable),e(mr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],wr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(h("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(mr.prototype,"destroy",(function(e){var t;return this._destroyed||(t=this,this._destroyed=!0,f((function(){e&&(wr("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(mr,"objectMode",vr),e(mr,"factory",_r);export{mr as default,_r as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 36b58da..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","CircularArrayStream","isCollection","DEFAULTS","JSON","stringify","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","FLG","_destroyed","_i","_iter","_src","_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 87586bf..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a89be25695244b9390ff2a4b0d30eee31cf7c43f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 07:50:59 +0000 Subject: [PATCH 025/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 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 | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ----- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 47 files changed, 4082 insertions(+), 6043 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 8c2a8f0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:03:31.792Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..af280f0 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(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 T(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 M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var Me=Te,ke=xe;function Pe(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===Te||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof k.setTimeout&&(Me=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=Mt;var xt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){xt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(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?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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?Ie(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,It(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!==qt(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},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..572b6dc --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2aaadb6..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..c218c2d --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 2a326d6e308a006f7111370a887a14c624d42417 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:04:01 +0000 Subject: [PATCH 026/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index ab84db4..41747f2 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 ecfb42cca56435bd904fcc1dbc08c21db8b129d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 14:38:20 +0000 Subject: [PATCH 027/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4364 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af280f0..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(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 T(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 M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var Me=Te,ke=xe;function Pe(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===Te||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof k.setTimeout&&(Me=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=Mt;var xt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){xt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(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?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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?Ie(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,It(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!==qt(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},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 572b6dc..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer' ;\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;41wDA2DA,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,YAGtDV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,QAAS,OAAQP,EAAKe,OAGjDZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,QAAS,MAAOP,EAAKiB,MAG9C,KA5CC,IAAIX,UAAWC,EAAQ,QAASN,GA6CzC,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAGvC,GADAvB,EAAO6B,EAAMC,IACRJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAO6B,EAAM5B,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCdA,SAASoC,GAASnC,GACjB,IAAID,EAMJ,OAJCA,EADI0B,UAAUC,OACPE,EAAM5B,EAAS,GAEf,CAAA,EAEDoC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFuJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,QAASkC,KAG/BjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c218c2d..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 5c72390674250876920dd7fdb88d2fdb03993614 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 14:39:14 +0000 Subject: [PATCH 028/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ----- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 47 files changed, 4082 insertions(+), 6048 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 4babc06..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:53:03.259Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..af280f0 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(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 T(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 M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var Me=Te,ke=xe;function Pe(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===Te||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof k.setTimeout&&(Me=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=Mt;var xt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){xt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(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?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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?Ie(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,It(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!==qt(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},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8aea9db --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 41747f2..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..a142339 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 a01776abd6987a326dd7b63d9f528caff03b3279 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 02:57:45 +0000 Subject: [PATCH 029/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index fc7251a..66e0726 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 b30152fcc2b067cdad488f05a3d6d3603694eaa9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 12:34:51 +0000 Subject: [PATCH 030/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4364 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index af280f0..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(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 T(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 M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var Me=Te,ke=xe;function Pe(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===Te||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof k.setTimeout&&(Me=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=Mt;var xt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){xt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(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?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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?Ie(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,It(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!==qt(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},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8aea9db..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;41wDA2DA,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,YAGtDV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,QAAS,OAAQP,EAAKe,OAGjDZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,QAAS,MAAOP,EAAKiB,MAG9C,KA5CC,IAAIX,UAAWC,EAAQ,QAASN,GA6CzC,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAGvC,GADAvB,EAAO6B,EAAMC,IACRJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAO6B,EAAM5B,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCdA,SAASoC,GAASnC,GACjB,IAAID,EAMJ,OAJCA,EADI0B,UAAUC,OACPE,EAAM5B,EAAS,GAEf,CAAA,EAEDoC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFuJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,QAASkC,KAG/BjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a142339..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 56b291ddb9e528eb5a147311b55b341e0928587d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 12:35:41 +0000 Subject: [PATCH 031/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 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 | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ----- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 47 files changed, 4082 insertions(+), 6059 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 914c74b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:16:22.386Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..9e2f90b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(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 T(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 M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var Me=Te,ke=xe;function Pe(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===Te||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof k.setTimeout&&(Me=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=Mt;var xt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){xt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(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?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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?Ie(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,It(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!==qt(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},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..8aea9db --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 66e0726..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..c777744 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 f8be400ca6bfdb9b1ba4151dd98769da7298667b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:34:17 +0000 Subject: [PATCH 032/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index fc7251a..66e0726 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 3192c9b8c04004f779f6ad3d496c46bf48634177 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:48:58 +0000 Subject: [PATCH 033/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4364 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e2f90b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(e,t,r){if(t)e.call(r);else for(var n=e.length,i=M(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 T(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 M(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function xe(){throw new Error("clearTimeout has not been defined")}var Me=Te,ke=xe;function Pe(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===Te||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof k.setTimeout&&(Me=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=Mt;var xt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function Mt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new Mt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(xt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){xt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(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?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return xt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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?Ie(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,It(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!==qt(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},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 8aea9db..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 c777744..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 33cca1279ae12fb33fed00b48d1f334c5ce641ea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 13:49:46 +0000 Subject: [PATCH 034/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 47 files changed, 6215 insertions(+), 6059 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 2b9cc7a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:40:58.107Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 d1cfa79..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-circular-array" -click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..165497b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..69d8cbb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 66e0726..972931c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..3bf1f9e --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 13244f2256477e3889347145ce115c1e8777a48f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 06:31:02 +0000 Subject: [PATCH 035/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 2341a46..ca9d5a9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 1155400ac61dde895ba928df3f26758427c9ff98 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 15:37:15 +0000 Subject: [PATCH 036/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 165497b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 69d8cbb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 3bf1f9e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c9f41a6b156276dc6ceb6bb40f246bd8f9878a1d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 15:38:15 +0000 Subject: [PATCH 037/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 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 | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 47 files changed, 6215 insertions(+), 6194 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 b6cdbff..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T04:11:53.431Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..165497b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..69d8cbb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;g+wDA2DA,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,YAGtDV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,QAAS,OAAQP,EAAKe,OAGjDZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,QAAS,MAAOP,EAAKiB,MAG9C,KA5CC,IAAIX,UAAWC,EAAQ,QAASN,GA6CzC,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAGvC,GADAvB,EAAO6B,EAAMC,IACRJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAO6B,EAAM5B,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCdA,SAASoC,GAASnC,GACjB,IAAID,EAMJ,OAJCA,EADI0B,UAAUC,OACPE,EAAM5B,EAAS,GAEf,CAAA,EAEDoC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFuJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,QAASkC,KAG/BjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ca9d5a9..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..e0e00e9 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 3c96a6b02591a5a29aecf3b475ae5e663535489d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 07:04:29 +0000 Subject: [PATCH 038/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 2341a46..ca9d5a9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 0284ba1501524c68122fb81cdab85d1523a9f0c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 14:34:06 +0000 Subject: [PATCH 039/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 165497b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 69d8cbb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e0e00e9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1b984c6f42f4901dccc74c5fefa0fd511b8ffb8c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 14:35:12 +0000 Subject: [PATCH 040/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 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 | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 47 files changed, 6215 insertions(+), 6200 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 6618a8c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T04:48:55.259Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..51518e3 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..73a3194 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ca9d5a9..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..5c2c202 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 c0df6298bdbee0684f23161916741902571036c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 06:49:17 +0000 Subject: [PATCH 041/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 2341a46..ca9d5a9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 c6fcc2bdaacb3fd40330862b211acc11e133f8e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 14:14:07 +0000 Subject: [PATCH 042/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 51518e3..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 73a3194..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;y9wDA2DA,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,YAGtDV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,QAAS,OAAQP,EAAKe,OAGjDZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,QAAS,MAAOP,EAAKiB,MAG9C,KA5CC,IAAIX,UAAWC,EAAQ,QAASN,GA6CzC,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAGvC,GADAvB,EAAO6B,EAAMC,IACRJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAO6B,EAAM5B,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCdA,SAASoC,GAASnC,GACjB,IAAID,EAMJ,OAJCA,EADI0B,UAAUC,OACPE,EAAM5B,EAAS,GAEf,CAAA,EAEDoC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFuJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,QAASkC,KAG/BjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c2c202..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c53be8f27a22e70f6071af96d95653caea3cefa8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 14:15:05 +0000 Subject: [PATCH 043/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 47 files changed, 6215 insertions(+), 6200 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 7475845..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T04:33:09.394Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..165497b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..69d8cbb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;g+wDA2DA,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,YAGtDV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,QAAS,OAAQP,EAAKe,OAGjDZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,QAAS,MAAOP,EAAKiB,MAG9C,KA5CC,IAAIX,UAAWC,EAAQ,QAASN,GA6CzC,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAGvC,GADAvB,EAAO6B,EAAMC,IACRJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAO6B,EAAM5B,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCdA,SAASoC,GAASnC,GACjB,IAAID,EAMJ,OAJCA,EADI0B,UAAUC,OACPE,EAAM5B,EAAS,GAEf,CAAA,EAEDoC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFuJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,QAASkC,KAG/BjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ca9d5a9..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..7216bd8 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 99a029e35bcae4457b7d15a884a1c910efcaeabe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 06:30:35 +0000 Subject: [PATCH 044/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 2341a46..ca9d5a9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 37f278782386981bf040914120d1d2dd7a4105dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 14:32:52 +0000 Subject: [PATCH 045/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 165497b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 69d8cbb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 7216bd8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ebf4a2acf917f5125256725c9ff009b7fabf1a16 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 14:33:48 +0000 Subject: [PATCH 046/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 47 files changed, 6215 insertions(+), 6200 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 e9e592f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T04:11:11.450Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 63f775a..ef3b255 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..165497b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..69d8cbb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ca9d5a9..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..558827b --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 cb5c98730a30b95c107ca69febf19bd0a6fe7021 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 20:05:11 +0000 Subject: [PATCH 047/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 2341a46..ca9d5a9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 13c9017d0f0827fb5bfe876034472cbbcfcb8a17 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 20:05:40 +0000 Subject: [PATCH 048/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 ef3b255..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 165497b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 69d8cbb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 558827b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1e6c419e1727362d4d2618158d4046a3d92bdf13 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 20:06:49 +0000 Subject: [PATCH 049/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 46 files changed, 6215 insertions(+), 6199 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 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 489f32f..f604e54 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..165497b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..69d8cbb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;g+wDA2DA,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,YAGtDV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,QAAS,OAAQP,EAAKe,OAGjDZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,QAAS,MAAOP,EAAKiB,MAG9C,KA5CC,IAAIX,UAAWC,EAAQ,QAASN,GA6CzC,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAGvC,GADAvB,EAAO6B,EAAMC,IACRJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAO6B,EAAM5B,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCdA,SAASoC,GAASnC,GACjB,IAAID,EAMJ,OAJCA,EADI0B,UAAUC,OACPE,EAAM5B,EAAS,GAEf,CAAA,EAEDoC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFuJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,QAASkC,KAG/BjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ca9d5a9..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..7d23117 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 85ff36db3bdbae914d6ebd289ffdcfadeedd8ca4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 06:31:14 +0000 Subject: [PATCH 050/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index 2f34b82..7712528 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index 4f76e88..978b7fc 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = copy( options, 1 ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 2341a46..ca9d5a9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,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 39ef386493c224222a63983a5cd554063cd24ed2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 14:46:50 +0000 Subject: [PATCH 051/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 f604e54..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 165497b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 69d8cbb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 7d23117..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f58178dd5b40276c5ea942fbc8b41e5db4ddded0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 14:48:04 +0000 Subject: [PATCH 052/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 47 files changed, 6215 insertions(+), 6200 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 b45790f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T04:10:58.698Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 489f32f..f604e54 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..165497b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..69d8cbb --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;g+wDA2DA,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,YAGtDV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,QAAS,OAAQP,EAAKe,OAGjDZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,QAAS,MAAOP,EAAKiB,MAG9C,KA5CC,IAAIX,UAAWC,EAAQ,QAASN,GA6CzC,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,QAASgB,IAGvC,GADAvB,EAAO6B,EAAMC,IACRJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,QAASP,IAEvCA,EAAO6B,EAAM5B,EAAS,EACxB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCdA,SAASoC,GAASnC,GACjB,IAAID,EAMJ,OAJCA,EADI0B,UAAUC,OACPE,EAAM5B,EAAS,GAEf,CAAA,EAEDoC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFuJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,QAASkC,KAG/BjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 943405f..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = copy( options, 1 ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 7712528..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 978b7fc..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = copy( options, 1 ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ca9d5a9..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..b0481c7 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 ecf69fac4246c86d641fe2465618b43554a6a199 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:41:24 +0000 Subject: [PATCH 053/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index f2cd20f..b0c0d20 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..3698d25 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 6fd2f15..5a41a16 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 12de044b5e7c993ffa29de5e22eff2b1ffd24cd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:43:23 +0000 Subject: [PATCH 054/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 f604e54..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 165497b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:S(r,f,this,arguments[1],arguments[2]);break;case 4:j(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;default:if(n)return Se(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 je(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}jt.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},jt.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},jt.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 jt(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i(dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i(t,1)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i(e,1):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 69d8cbb..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', 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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","copy","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 b0481c7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3b3bfc70626bb697f77b47743ad4f7c58fab3c78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:44:21 +0000 Subject: [PATCH 055/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 46 files changed, 6215 insertions(+), 6199 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 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 489f32f..f604e54 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..b984de5 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i({},t)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b47940d --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 b0c0d20..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 3698d25..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 5a41a16..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..8a95d43 --- /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 e410971..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 36dcb9e..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 855b587..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 5b89da3..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 0573bbf..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 a094abcfbdec8c0828f4d64e5a8bdef5cbd081f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 07:01:25 +0000 Subject: [PATCH 056/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index f2cd20f..b0c0d20 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '0fzAu', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '0fz2a', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..3698d25 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '0fz2h', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..28992dc 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '0fz35', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '0fz37', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 6fd2f15..5a41a16 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 40c4329ba051f64c8c462c95743618ac296ee795 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 15:38:28 +0000 Subject: [PATCH 057/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 f604e54..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b984de5..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i({},t)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b47940d..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 8a95d43..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a46f840b62c91db0a6ab5d85187b243ad6c2dbef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 15:39:34 +0000 Subject: [PATCH 058/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 47 files changed, 6215 insertions(+), 6200 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 2680fff..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T04:35:55.908Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # 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 + + ```
@@ -299,7 +298,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]. @@ -367,11 +366,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 489f32f..f604e54 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..b984de5 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i({},t)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b47940d --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 b0c0d20..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '0fz2a', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 3698d25..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '0fz2h', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 28992dc..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '0fz2h', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '0fz2i', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fz30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '0fz84', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fz4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '0fz78', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '0fz35', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '0fz37', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 5a41a16..5eea023 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a readable stream from a circular 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,54 +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-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..f09116c --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 4e5657ec2bd1c1d8df3fc8506b57d2ae468e93ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 20:57:14 +0000 Subject: [PATCH 059/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index f2cd20f..76ac7e7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9,PU', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O,GW', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..df95eb2 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V,FD', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..560af43 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 555ad3f..e124125 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/buffer-ctor": "^0.1.0", "@stdlib/buffer-from-string": "^0.1.0", "@stdlib/object-assign": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-property": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", From 97725dd5641085cf4c3bad3e8dc6988a03cd506c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:07:40 +0000 Subject: [PATCH 060/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 f604e54..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b984de5..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@esm/index.mjs";import a 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 h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@esm/index.mjs";import{isPrimitive as y}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 v(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],C=[],O="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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;B||U();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 I(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?z(e):z(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function we(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 ve(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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),I(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),I(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),I(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),I(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):we(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):we(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ye(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):ve(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 O(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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Ce,Oe=[],Be=!1,Ue=-1;function De(){Be&&Ce&&(Be=!1,Ce.length?Oe=Ce.concat(Oe):Ue=-1,Oe.length&&ze())}function ze(){if(!Be){var e=Pe(De);Be=!0;for(var t=Oe.length;t;){for(Ce=Oe,Oe=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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)),vt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(wt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(vt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),wt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),vt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function wt(e){return yt(e)&&"[object Date]"===bt(e)}function vt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ot(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&&Ot(e))),function(e,t){t.readingMore||(t.readingMore=!0,Ie(Ut,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 Ot(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Ie(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),It(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Ie(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ot(this),null;if(0===(e=Ct(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?Ie(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,It(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?Ie(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys($t.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function wr(r,n){var o,a;if(!(this instanceof wr))return arguments.length>1?new wr(r,n):new wr(r);if(!t(r))throw new TypeError(f("0fz2a",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function vr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("0fz2h",r));r=i({},t)}else r={};return r.objectMode=!0,new wr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new wr(e,t)}}o(wr,yr),e(wr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("0fzAu",r))),t?this.emit("error",t):e=this.push(r)}})),e(wr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(wr,"objectMode",vr),e(wr,"factory",mr);export{wr as default,mr as factory,vr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b47940d..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '0fz2h', 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( '0fz2i', '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( '0fz30', '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( '0fz84', '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( '0fz4x', '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( '0fz78', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '0fz35', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '0fz37', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '0fzAu', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '0fz2a', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '0fz2h', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 f09116c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e8866787c88077eff5612970d5aa105fa8a7ee3c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:09:30 +0000 Subject: [PATCH 061/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 50 files changed, 6215 insertions(+), 6242 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 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/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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 80c47eb..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-circular-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 a4864f2..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: '34 22 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -310,7 +309,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]. @@ -378,11 +377,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b7fe578..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ne,S){S.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(se,m){ -var T=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function W(e,r){return T(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=W -});var y=u(function(ue,_){ -var A=require("debug"),F=A("from-circular-array-stream");_.exports=F -});var l=u(function(oe,w){ -var q=require("readable-stream").Readable,P=require('@stdlib/assert-is-collection/dist'),V=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=y();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",V(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!P(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var j=u(function(de,M){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}M.exports=Z -});var x=u(function(le,O){ -var $=require('@stdlib/object-assign/dist'),ee=l();function re(e){var r;return arguments.length?r=$({},e):r={},i;function i(d){return new ee(d,r)}}O.exports=re -});var E=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ie=j(),te=x();E(v,"objectMode",ie);E(v,"factory",te);module.exports=v; -/** @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 091e840..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 cf6902b..8fdadfd 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..3752de0 --- /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@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr 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..3a8d89c --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 76ac7e7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O,GW', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index df95eb2..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V,FD', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 560af43..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V,FD', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W,Gh', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n,Ny', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p,Fu', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index e124125..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/assert-is-buffer": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-error": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-number": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.0", - "@stdlib/buffer-from-string": "^0.1.0", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-property": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-inherit": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.0", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/streams-node-inspect-sink": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..87556be --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 3a60750cbbb1c6871b7e9d57c44ac394901f820f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:11:48 +0000 Subject: [PATCH 062/138] Update README.md for ESM bundle v0.1.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de40e54..8b763f0 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.1.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-circular-array@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.1.0-esm/index.mjs'; ``` @@ -245,7 +245,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.1.0-esm/index.mjs'; function log( v ) { console.log( v.toString() ); From b6997e1616d3371e9370f563475cb7048746beab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:11:48 +0000 Subject: [PATCH 063/138] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b763f0..761a9a7 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-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-circular-array/tags). For example, + ```javascript import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.1.0-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-n 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-circular-array@v0.1.0-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; ``` @@ -245,7 +250,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.1.0-esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 253ef11036be3376cd7cdbf11b30556d5c567e6c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 08:27:43 +0000 Subject: [PATCH 064/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index f2cd20f..76ac7e7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9,PU', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O,GW', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..df95eb2 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V,FD', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..560af43 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index c64a693..91fff15 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@stdlib/buffer-ctor": "^0.1.0", "@stdlib/buffer-from-string": "^0.1.0", "@stdlib/object-assign": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-property": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", From 8950ff77e52751fbfbfdf813efb52680e5419f29 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 14:04:07 +0000 Subject: [PATCH 065/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 8fdadfd..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3752de0..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@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-error@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 3a8d89c..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 87556be..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6d040c7eb3bd76feb627c4398f13759d0779fd3b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 14:07:26 +0000 Subject: [PATCH 066/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 43 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 52 files changed, 6215 insertions(+), 6344 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4fa1190..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T03:01:30.868Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7d4ef6a..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-circular-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 c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index e39dd04..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: '34 22 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -310,7 +309,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]. @@ -378,11 +377,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b7fe578..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ne,S){S.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(se,m){ -var T=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function W(e,r){return T(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=W -});var y=u(function(ue,_){ -var A=require("debug"),F=A("from-circular-array-stream");_.exports=F -});var l=u(function(oe,w){ -var q=require("readable-stream").Readable,P=require('@stdlib/assert-is-collection/dist'),V=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=y();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",V(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!P(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var j=u(function(de,M){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}M.exports=Z -});var x=u(function(le,O){ -var $=require('@stdlib/object-assign/dist'),ee=l();function re(e){var r;return arguments.length?r=$({},e):r={},i;function i(d){return new ee(d,r)}}O.exports=re -});var E=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ie=j(),te=x();E(v,"objectMode",ie);E(v,"factory",te);module.exports=v; -/** @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 091e840..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 cf6902b..8fdadfd 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..e8c2245 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr 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..47d68f7 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 76ac7e7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O,GW', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index df95eb2..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V,FD', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 560af43..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V,FD', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W,Gh', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n,Ny', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p,Fu', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 91fff15..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/assert-is-buffer": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-error": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-nonnegative-number": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/buffer-ctor": "^0.1.0", - "@stdlib/buffer-from-string": "^0.1.0", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-property": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-inherit": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.0", - "debug": "^2.6.9", - "readable-stream": "^2.1.4" - }, - "devDependencies": { - "@stdlib/array-float64": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/streams-node-inspect-sink": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..afb30c5 --- /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 976414a..0000000 --- a/test/dist/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 circularArrayStream = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 52fb145ff759f1ea6d638fbdb49c1b172b5dca50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 12:07:46 +0000 Subject: [PATCH 067/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index f2cd20f..76ac7e7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9,PU', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O,GW', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..df95eb2 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V,FD', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..560af43 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index bb85e0f..63c500b 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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.1.0", "@stdlib/utils-define-nonenumerable-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", From 928a2c8ef8362ac3ec7e149cfdab5cc609ee569c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 15:47:08 +0000 Subject: [PATCH 068/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 8fdadfd..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e8c2245..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 47d68f7..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 afb30c5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eb851e8a194770db3ace1f905531ee153a947a88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 15:51:12 +0000 Subject: [PATCH 069/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 43 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 51 files changed, 6215 insertions(+), 6343 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7d4ef6a..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-circular-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 c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index e39dd04..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: '34 22 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -310,7 +309,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]. @@ -378,11 +377,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b7fe578..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ne,S){S.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(se,m){ -var T=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function W(e,r){return T(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=W -});var y=u(function(ue,_){ -var A=require("debug"),F=A("from-circular-array-stream");_.exports=F -});var l=u(function(oe,w){ -var q=require("readable-stream").Readable,P=require('@stdlib/assert-is-collection/dist'),V=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=y();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",V(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!P(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var j=u(function(de,M){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}M.exports=Z -});var x=u(function(le,O){ -var $=require('@stdlib/object-assign/dist'),ee=l();function re(e){var r;return arguments.length?r=$({},e):r={},i;function i(d){return new ee(d,r)}}O.exports=re -});var E=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ie=j(),te=x();E(v,"objectMode",ie);E(v,"factory",te);module.exports=v; -/** @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 091e840..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 cf6902b..8fdadfd 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..d00ec29 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import v 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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr 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..47d68f7 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 76ac7e7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O,GW', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index df95eb2..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V,FD', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 560af43..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V,FD', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W,Gh', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n,Ny', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p,Fu', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 63c500b..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +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-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.1.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.0", - "@stdlib/bench": "^0.1.0", - "@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" - }, - "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..d120476 --- /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 976414a..0000000 --- a/test/dist/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 circularArrayStream = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 d0b31b67ad66101b4d64c6ee987fa1a2469305dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 08:36:15 +0000 Subject: [PATCH 070/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index f2cd20f..76ac7e7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9,PU', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O,GW', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..df95eb2 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V,FD', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..560af43 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index b0d8ecc..eb3d8ad 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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.1.0", "@stdlib/utils-define-nonenumerable-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", From 11c4bde495df36c50a2111c7f297305a9e280a70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 15:11:39 +0000 Subject: [PATCH 071/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 8fdadfd..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d00ec29..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import v 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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 47d68f7..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 d120476..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 090d9260e2fc33bfb5198d8c41717ad7dbd85360 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 15:15:04 +0000 Subject: [PATCH 072/138] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 52 files changed, 6215 insertions(+), 6342 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bc73654..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T03:08:50.437Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7d4ef6a..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-circular-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 c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index e39dd04..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: '34 22 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -310,7 +309,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]. @@ -378,11 +377,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b7fe578..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ne,S){S.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(se,m){ -var T=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function W(e,r){return T(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=W -});var y=u(function(ue,_){ -var A=require("debug"),F=A("from-circular-array-stream");_.exports=F -});var l=u(function(oe,w){ -var q=require("readable-stream").Readable,P=require('@stdlib/assert-is-collection/dist'),V=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=y();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",V(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!P(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var j=u(function(de,M){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}M.exports=Z -});var x=u(function(le,O){ -var $=require('@stdlib/object-assign/dist'),ee=l();function re(e){var r;return arguments.length?r=$({},e):r={},i;function i(d){return new ee(d,r)}}O.exports=re -});var E=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ie=j(),te=x();E(v,"objectMode",ie);E(v,"factory",te);module.exports=v; -/** @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 091e840..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 73b5650..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 cf6902b..8fdadfd 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..d00ec29 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import v 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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr 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..47d68f7 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 76ac7e7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O,GW', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index df95eb2..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V,FD', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 560af43..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V,FD', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W,Gh', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n,Ny', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p,Fu', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index eb3d8ad..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +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-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.1.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/bench": "^0.1.0", - "@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" - }, - "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..4e0cd51 --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 a221775bb109af5211ff2d8ab40ac42166f1b2b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 07:23:42 +0000 Subject: [PATCH 073/138] Transform error messages --- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/main.js b/lib/main.js index f2cd20f..76ac7e7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9,PU', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O,GW', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..df95eb2 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V,FD', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..560af43 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 701bf12..a98c5d9 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 d65120efcb871c7ef27596e6dd87e3d3bf44c878 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 02:38:37 +0000 Subject: [PATCH 074/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 8fdadfd..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d00ec29..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import v 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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 47d68f7..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 4e0cd51..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 488e51bbd50cedaa46932b8231f32329f8ef5773 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 02:41:09 +0000 Subject: [PATCH 075/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 52 files changed, 6215 insertions(+), 6337 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 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 dc6cb2f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T03:19:31.318Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7d4ef6a..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-circular-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 c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index e39dd04..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: '34 22 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -310,7 +309,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]. @@ -378,11 +377,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5a49732..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 63ee387..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b7fe578..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ne,S){S.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(se,m){ -var T=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function W(e,r){return T(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=W -});var y=u(function(ue,_){ -var A=require("debug"),F=A("from-circular-array-stream");_.exports=F -});var l=u(function(oe,w){ -var q=require("readable-stream").Readable,P=require('@stdlib/assert-is-collection/dist'),V=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=y();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",V(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!P(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var j=u(function(de,M){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}M.exports=Z -});var x=u(function(le,O){ -var $=require('@stdlib/object-assign/dist'),ee=l();function re(e){var r;return arguments.length?r=$({},e):r={},i;function i(d){return new ee(d,r)}}O.exports=re -});var E=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ie=j(),te=x();E(v,"objectMode",ie);E(v,"factory",te);module.exports=v; -/** @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 091e840..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 cf6902b..8fdadfd 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..d00ec29 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import v 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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr 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..47d68f7 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 76ac7e7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O,GW', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index df95eb2..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V,FD', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 560af43..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V,FD', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W,Gh', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n,Ny', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p,Fu', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index a98c5d9..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +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-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/bench": "^0.2.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" - }, - "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..faa597a --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 bec61e08b36fa89663f3199de4fea758f0c2f658 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:41:56 +0000 Subject: [PATCH 076/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 16c65fc..7ad6d8f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 15ca6e1304c829035c252e3cd8de0e2425f17315 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 11:00:43 +0000 Subject: [PATCH 077/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 8fdadfd..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d00ec29..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";import v 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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 L(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 T(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}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},P=[],B=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,O=!1;function U(){O=!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 I(e){var t;O||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ye(e,t,r,n,i,o){if(!K(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 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 me(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 be(e,t,r,n,i){return i||me(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||me(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ye(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||ye(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||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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);ye(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);ye(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||ye(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||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ve(this,e,t,!0),t+2},H.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ye(this,e,t,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ve(this,e,t,!1),t+2},H.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ye(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||ye(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 be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;O||U();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 C(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=B[e.charCodeAt(t)]<<2|B[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=B[e.charCodeAt(t)]<<10|B[e.charCodeAt(t+1)]<<4|B[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(Ee,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Me(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ae(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Le(){throw new Error("setTimeout has not been defined")}function Te(){throw new Error("clearTimeout has not been defined")}var xe=Le,ke=Te;function Pe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Le||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Be,Ce=[],Oe=!1,Ue=-1;function De(){Oe&&Be&&(Oe=!1,Be.length?Ce=Be.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Oe){var e=Pe(De);Oe=!0;for(var t=Ce.length;t;){for(Be=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&mt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(mt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(vt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(wt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),mt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),vt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),wt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return yt(e)&&"[object RegExp]"===bt(e)}function yt(e){return"object"==typeof e&&null!==e}function vt(e){return yt(e)&&"[object Date]"===bt(e)}function wt(e){return yt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function mt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!yt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=At;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Lt;break;default:return void(this.write=Mt)}this.charBuffer=new H(6),this.charReceived=0,this.charLength=0}function Mt(e){return e.toString(this.encoding)}function At(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Lt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Tt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Tt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Ot,e):Ot(e))}function Ot(e){Tt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Tt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Bt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Tt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Tt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Tt("onunpipe"),e===r&&h()}function s(){Tt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Tt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Tt("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){Tt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Tt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Tt("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(){Tt("onfinish"),e.removeListener("close",d),g()}function g(){Tt("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||(Tt("pipe resume"),r.resume()),e},kt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Gt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),yr=cr.Readable;function vr(r,n){var o,a;if(!(this instanceof vr))return arguments.length>1?new vr(r,n):new vr(r);if(!t(r))throw new TypeError(f("1MB2O,GW",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),yr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function wr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V,FD",r));r=i({},t)}else r={};return r.objectMode=!0,new vr(e,r)}function mr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new vr(e,t)}}o(vr,yr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9,PU",r))),t?this.emit("error",t):e=this.push(r)}})),e(vr.prototype,"destroy",(function(e){var t;return this._destroyed?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(vr,"objectMode",wr),e(vr,"factory",mr);export{vr as default,mr as factory,wr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 47d68f7..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V,FD', 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( '1MB2W,Gh', '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( '1MB2o,GE', '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( '1MB7n,Ny', '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( '1MB4k,I9', '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( '1MB6p,Fu', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t,G9', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v,MP', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9,PU', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O,GW', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V,FD', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 faa597a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 569b07b7fa94c1fe0d634d0d4571d11050fcb248 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 11:01:09 +0000 Subject: [PATCH 078/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 94 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 53 files changed, 6215 insertions(+), 6343 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 a0784ad..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:52:04.993Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 3e1377d..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: '34 22 * * 2' - - # 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 + + ```
@@ -310,7 +309,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]. @@ -378,11 +377,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b7fe578..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ne,S){S.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(se,m){ -var T=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function W(e,r){return T(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=W -});var y=u(function(ue,_){ -var A=require("debug"),F=A("from-circular-array-stream");_.exports=F -});var l=u(function(oe,w){ -var q=require("readable-stream").Readable,P=require('@stdlib/assert-is-collection/dist'),V=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=y();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",V(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!P(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var j=u(function(de,M){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}M.exports=Z -});var x=u(function(le,O){ -var $=require('@stdlib/object-assign/dist'),ee=l();function re(e){var r;return arguments.length?r=$({},e):r={},i;function i(d){return new ee(d,r)}}O.exports=re -});var E=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ie=j(),te=x();E(v,"objectMode",ie);E(v,"factory",te);module.exports=v; -/** @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 091e840..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 cf6902b..8fdadfd 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..7c53c9b --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr 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..f4c4798 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 518b108..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 f2cd20f..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index ecb84cb..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - 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 CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 9372d68..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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 ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 7ad6d8f..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +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-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..77fba6e --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 ef5008cc5dc4cbaf9acd9c7ae30c65c7cce8b502 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Jan 2024 23:22:23 +0000 Subject: [PATCH 079/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 16c65fc..7ad6d8f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 a1bb046eda6914e9ee0b914d2849185a0407e720 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Jan 2024 23:22:58 +0000 Subject: [PATCH 080/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 8fdadfd..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7c53c9b..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;return t=arguments.length?i({},e):{},r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f4c4798..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 77fba6e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1d0ced149d6d1ae85329ffc9f0ca1eb246777195 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Jan 2024 23:23:27 +0000 Subject: [PATCH 081/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 61 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 52 files changed, 6215 insertions(+), 6348 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 14dba89..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-circular-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 7d4ef6a..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-circular-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 3e1377d..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: '34 22 * * 2' - - # 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 + + ```
@@ -310,7 +309,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]. @@ -378,11 +377,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 ef10218..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..27587d8 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",e));t=i({},e)}else t={};return r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr 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..7fa6353 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 6bfd8f3..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -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 a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 f2cd20f..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index ecb84cb..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - 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 CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 9372d68..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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 ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 7ad6d8f..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +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-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..55f4cb0 --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 462d06f1ff4d30790a42aa58ccd3101ff70bc793 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 05:08:27 +0000 Subject: [PATCH 082/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 16c65fc..7ad6d8f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 5db10d87f05c8eeee85489e4e57efe43f55f999a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:23:27 +0000 Subject: [PATCH 083/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27587d8..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",e));t=i({},e)}else t={};return r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7fa6353..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 55f4cb0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2149ea7966d5935ffecabbefb655d4530feb50f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:23:54 +0000 Subject: [PATCH 084/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 53 files changed, 6215 insertions(+), 6354 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 314f792..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T03:27:24.771Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 3e1377d..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..27587d8 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",e));t=i({},e)}else t={};return r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr 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..7fa6353 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 6bfd8f3..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -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 a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 f2cd20f..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index ecb84cb..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - 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 CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 9372d68..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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 ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 7ad6d8f..091167c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a readable stream from a circular 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,54 +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-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..dffaca5 --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 0fa955e4ff090d8ccbc4af587ed25fefd651ec4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 09:05:03 +0000 Subject: [PATCH 085/138] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 998c3cf..2654935 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 8dcad2008ba34d9bd64d7991115255e2f8054979 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 17:50:56 +0000 Subject: [PATCH 086/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27587d8..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.1.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",e));t=i({},e)}else t={};return r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7fa6353..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;ilxDA2DA,SAASA,GAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,SACzBD,EAAKI,IAAMH,EAAQG,KACbC,EAAUL,EAAKI,MACb,IAAIE,UAAWC,EAAQ,8DAA+D,MAAOP,EAAKI,MAGtGD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,+DAAgE,aAAcP,EAAKQ,aAG9GL,EAAYF,EAAS,cACzBD,EAAKU,SAAWT,EAAQS,UAClBL,EAAUL,EAAKU,WAAgC,OAAlBV,EAAKU,UAChC,IAAIJ,UAAWC,EAAQ,sEAAuE,WAAYP,EAAKU,WAGnHP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBC,EAAeZ,EAAKW,gBAClB,IAAIL,UAAWC,EAAQ,0EAA2E,gBAAiBP,EAAKW,gBAG5HR,EAAYF,EAAS,eACzBD,EAAKa,UAAYZ,EAAQY,WACnBC,EAAYd,EAAKa,YACf,IAAIP,UAAWC,EAAQ,gEAAiE,YAAaP,EAAKa,YAG9GV,EAAYF,EAAS,UACzBD,EAAKe,KAAOd,EAAQc,MACdC,EAAsBhB,EAAKe,OACzB,IAAIT,UAAWC,EAAQ,2EAA4E,OAAQP,EAAKe,OAGpHZ,EAAYF,EAAS,SACzBD,EAAKiB,IAAMhB,EAAQgB,IACD,IAAbjB,EAAKiB,MAA2B,IAAdjB,EAAKiB,KACpB,IAAIX,UAAWC,EAAQ,wEAAyE,MAAOP,EAAKiB,MAG9G,KA5CC,IAAIX,UAAWC,EAAQ,qEAAsEN,GA6CtG,KC/EIiB,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKtB,GAClC,IAAID,EACAwB,EACJ,KAAQC,gBAAgBH,IACvB,OAAKI,UAAUC,OAAS,EAChB,IAAIL,GAAqBC,EAAKtB,GAE/B,IAAIqB,GAAqBC,GAEjC,IAAMK,EAAcL,GACnB,MAAM,IAAIjB,UAAWC,EAAQ,8EAA+EgB,IAG7G,GADAvB,EAAO6B,EAAQ,GAAIC,IACdJ,UAAUC,OAAS,IACvBH,EAAMzB,GAAUC,EAAMC,IAErB,MAAMuB,EAkCR,OA9BAN,GAAO,wEAAyEa,KAAKC,UAAWhC,IAChGoB,GAASa,KAAMR,KAAMzB,GAGrBkC,EAAkBT,KAAM,cAAc,GAGtCU,EAA0BV,KAAM,cAAezB,EAAKQ,YAGpD2B,EAA0BV,KAAM,OAAQzB,EAAKI,KAG7C+B,EAA0BV,KAAM,aAAczB,EAAKa,WAAakB,KAAKC,WAGrEG,EAA0BV,KAAM,OAAQF,GAGxCY,EAA0BV,KAAM,UAAWzB,EAAKiB,KAGhDkB,EAA0BV,KAAM,QAASzB,EAAKe,MAG9CmB,EAAkBT,KAAM,KAAM,GAG9BS,EAAkBT,KAAM,OAAuB,IAAbzB,EAAKiB,KAAe,EAAIM,EAAII,QAEvDF,IACR,CCvKA,SAASjB,GAAYe,EAAKtB,GACzB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,EAAI,CAE3B,IAAMzB,EADNF,EAAOC,GAEN,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEP,IAEpGA,EAAO6B,EAAQ,GAAI5B,EACrB,MACED,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,EACX,IAAIc,GAAqBC,EAAKvB,EACtC,CCXA,SAASoC,GAASnC,GACjB,IAAID,EACJ,GAAK0B,UAAUC,OAAS,CACvB,IAAMzB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAO6B,EAAQ,GAAI5B,EACrB,MACED,EAAO,CAAA,EAER,OAAOqC,EAYP,SAASA,EAAcd,GACtB,OAAO,IAAID,GAAqBC,EAAKvB,EACrC,CACF,CFiJAsC,EAAShB,GAAqBF,IAY9Be,EAA0Bb,GAAoBiB,UAAW,SA3MzD,WAEC,IAAIC,EACAhB,EACAiB,EAEJ,IAAKhB,KAAKiB,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhB,EAAM,KAENC,KAAKkB,IAAM,EACNlB,KAAKkB,GAAKlB,KAAKmB,OAA8B,IAArBnB,KAAKoB,KAAKlB,OAEtC,OADAT,GAAO,uBACAO,KAAKqB,KAAM,MAEnBrB,KAAKsB,MAAQtB,KAAKuB,QACbvB,KAAKuB,QAAU,GAAKvB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OAC/CF,KAAKsB,MAAQtB,KAAKoB,KAAKlB,OACZF,KAAKuB,QAAU,GAAKvB,KAAKsB,KAAO,IAC3CtB,KAAKsB,MAAQtB,KAAKoB,KAAKlB,QAExBc,EAAIhB,KAAKoB,KAAMpB,KAAKsB,MACpB7B,GAAO,gCAAiCa,KAAKC,UAAWS,GAAKhB,KAAKsB,KAAMtB,KAAKkB,KAEnD,IAArBlB,KAAKwB,cAES,iBADlBR,EAAIhB,KAAKyB,WAAYT,IAGnBA,EADgB,IAAZhB,KAAKkB,GACLQ,EAAeV,GAEfU,EAAe1B,KAAK2B,KAAKX,GAEnBY,EAAUZ,GAChBhB,KAAKkB,GAAK,IACdF,EAAIa,EAAOC,OAAQ,CAAEJ,EAAe1B,KAAK2B,MAAQX,KAGlDjB,EAAM,IAAIgC,MAAOjD,EAAQ,yFAA0FkC,KAGhHjB,EACJC,KAAKgC,KAAM,QAASjC,GAEpBgB,EAAMf,KAAKqB,KAAML,EAElB,CAGF,IAmKAN,EAA0Bb,GAAoBiB,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlC,KAAKiB,YACTxB,GAAO,qDACAO,OAERkC,EAAOlC,KACPA,KAAKiB,YAAa,EAElBkB,GASA,WACMF,IACJxC,GAAO,mDAAsD2C,EAASH,GAAYA,EAAMI,QAAU/B,KAAKC,UAAW0B,IAClHC,EAAKF,KAAM,QAASC,IAErBxC,GAAO,yBACPyC,EAAKF,KAAM,QACX,IAdMhC,KAiBR,IG1BAsC,EAAAC,GAAA,aAAAxD,IACAuD,EAAAC,GAAA,UAAA5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dffaca5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1820783bf50fae8aee46b3031788915786ddef93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 17:51:53 +0000 Subject: [PATCH 087/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 - 52 files changed, 6215 insertions(+), 6357 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 14dba89..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-circular-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 7d4ef6a..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-circular-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 1dad97a..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..cd6ca6d --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",e));t=i({},e)}else t={};return r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr 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..7fa6353 --- /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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 6bfd8f3..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -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 a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 f2cd20f..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index ecb84cb..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - 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 CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 9372d68..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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 ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2654935..83efbd9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a readable stream from a circular 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,54 +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-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..7cf719a --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 2bad383789c5ff5e8aea1a9005fa499add0594c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:05:08 +0000 Subject: [PATCH 088/138] 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 b504d52..88e3399 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-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-circular-array@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.0-esm/index.mjs'; ``` @@ -245,7 +245,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.0-esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 2d20cab9f8bd7350290297eba1367f69e714900f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:05:09 +0000 Subject: [PATCH 089/138] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 88e3399..8906586 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-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-circular-array/tags). For example, + ```javascript import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.0-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-n 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-circular-array@v0.2.0-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; ``` @@ -245,7 +250,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.0-esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 24b651cb2de4e71127248ea90cc173cdd368f177 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 16:41:09 +0000 Subject: [PATCH 090/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index 3d50cff..bfa2a0e 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 f376d2f6b7c2b16fff50217772d9386b2ae14f18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:29:08 +0000 Subject: [PATCH 091/138] Remove files --- index.d.ts | 315 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6497 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cd6ca6d..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.0-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.0-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.0-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.1.0-esm/index.mjs";import{isPrimitive as v}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 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 w(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 T(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 M(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}w.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new w,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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:E(r,f,this);break;case 2:R(r,f,this,arguments[1]);break;case 3:j(r,f,this,arguments[1],arguments[2]);break;case 4:S(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 w,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var k="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],P=[],C="undefined"!=typeof Uint8Array?Uint8Array:Array,B=!1;function U(){B=!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 I(e){var t;B||U();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 z(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 Y(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 N={}.toString,W=Array.isArray||function(e){return"[object Array]"==N.call(e)};function q(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function F(e,t){if(q()=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return 0|e}function K(e){return!(null==e||!e._isBuffer)}function Q(e,t){if(K(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 je(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Se(e).length;default:if(n)return je(e).length;t=(""+t).toLowerCase(),n=!0}}function X(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 de(this,t,r);case"utf8":case"utf-8":return fe(this,t,r);case"ascii":return le(this,t,r);case"latin1":case"binary":return ce(this,t,r);case"base64":return he(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function ee(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function te(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)),K(t))return 0===t.length?-1:re(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):re(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function re(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 he(e,t,r){return 0===t&&r===e.length?I(e):I(e.slice(t,r))}function fe(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(!K(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 ne(this,e,t,r);case"utf8":case"utf-8":return ie(this,e,t,r);case"ascii":return oe(this,e,t,r);case"latin1":case"binary":return se(this,e,t,r);case"base64":return ae(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ue(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 le(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 ve(e,t,r,n,i,o){if(!K(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 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 we(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 be(e,t,r,n,i){return i||we(e,0,r,4),Y(e,t,r,n,23,4),r+4}function _e(e,t,r,n,i){return i||we(e,0,r,8),Y(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||ge(e,1,this.length),this[e]},H.prototype.readUInt16LE=function(e,t){return t||ge(e,2,this.length),this[e]|this[e+1]<<8},H.prototype.readUInt16BE=function(e,t){return t||ge(e,2,this.length),this[e]<<8|this[e+1]},H.prototype.readUInt32LE=function(e,t){return t||ge(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||ge(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||ge(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||ge(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||ge(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},H.prototype.readInt16LE=function(e,t){t||ge(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||ge(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||ge(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||ge(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||ge(e,4,this.length),z(this,e,!0,23,4)},H.prototype.readFloatBE=function(e,t){return t||ge(e,4,this.length),z(this,e,!1,23,4)},H.prototype.readDoubleLE=function(e,t){return t||ge(e,8,this.length),z(this,e,!0,52,8)},H.prototype.readDoubleBE=function(e,t){return t||ge(e,8,this.length),z(this,e,!1,52,8)},H.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(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);ve(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);ve(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||ve(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||ve(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||ve(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||ve(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):me(this,e,t,!0),t+4},H.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ve(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):me(this,e,t,!1),t+4},H.prototype.writeFloatLE=function(e,t,r){return be(this,e,t,!0,r)},H.prototype.writeFloatBE=function(e,t,r){return be(this,e,t,!1,r)},H.prototype.writeDoubleLE=function(e,t,r){return _e(this,e,t,!0,r)},H.prototype.writeDoubleBE=function(e,t,r){return _e(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 Se(e){return function(e){var t,r,n,i,o,s;B||U();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 C(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=P[e.charCodeAt(t)]<<2|P[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=P[e.charCodeAt(t)]<<10|P[e.charCodeAt(t+1)]<<4|P[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(Ee,"")).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 Te(){throw new Error("setTimeout has not been defined")}function Me(){throw new Error("clearTimeout has not been defined")}var xe=Te,ke=Me;function Oe(e){if(xe===setTimeout)return setTimeout(e,0);if((xe===Te||!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 k.setTimeout&&(xe=setTimeout),"function"==typeof k.clearTimeout&&(ke=clearTimeout);var Pe,Ce=[],Be=!1,Ue=-1;function De(){Be&&Pe&&(Be=!1,Pe.length?Ce=Pe.concat(Ce):Ue=-1,Ce.length&&Ie())}function Ie(){if(!Be){var e=Oe(De);Be=!0;for(var t=Ce.length;t;){for(Pe=Ce,Ce=[];++Ue1)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]),lt(t)?r.showHidden=t:t&&_t(r,t),pt(r.showHidden)&&(r.showHidden=!1),pt(r.depth)&&(r.depth=2),pt(r.colors)&&(r.colors=!1),pt(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=st),ut(r,e,r.depth)}function st(e,t){var r=ot.styles[t];return r?"["+ot.colors[r][0]+"m"+e+"["+ot.colors[r][1]+"m":e}function at(e,t){return e}function ut(e,t,r){if(e.customInspect&&t&&wt(t.inspect)&&t.inspect!==ot&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return dt(n)||(n=ut(e,n,r)),n}var i=function(e,t){if(pt(t))return e.stylize("undefined","undefined");if(dt(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(lt(t))return e.stylize(""+t,"boolean");if(ct(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 ht(t);if(0===o.length){if(wt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(gt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(yt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(mt(t))return ht(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),wt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return gt(t)&&(f=" "+RegExp.prototype.toString.call(t)),yt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),mt(t)&&(f=" "+ht(t)),0!==o.length||l&&0!=t.length?r<0?gt(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 ht(e){return"["+Error.prototype.toString.call(e)+"]"}function ft(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")),Et(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ct(r)?ut(e,u.value,null):ut(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")),pt(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 lt(e){return"boolean"==typeof e}function ct(e){return null===e}function dt(e){return"string"==typeof e}function pt(e){return void 0===e}function gt(e){return vt(e)&&"[object RegExp]"===bt(e)}function vt(e){return"object"==typeof e&&null!==e}function yt(e){return vt(e)&&"[object Date]"===bt(e)}function mt(e){return vt(e)&&("[object Error]"===bt(e)||e instanceof Error)}function wt(e){return"function"==typeof e}function bt(e){return Object.prototype.toString.call(e)}function _t(e,t){if(!t||!vt(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function Et(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rt(){this.head=null,this.tail=null,this.length=0}ot.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]},ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Rt.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},Rt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Rt.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}},Rt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Rt.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},Rt.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 jt=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 St(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!jt(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=Tt;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 Tt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}St.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},St.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},St.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},kt.ReadableState=xt;var Mt=function(e){if(pt(nt)&&(nt=Qe.env.NODE_DEBUG||""),e=e.toUpperCase(),!it[e])if(new RegExp("\\b"+e+"\\b","i").test(nt)){it[e]=function(){var t=tt.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else it[e]=function(){};return it[e]}("stream");function xt(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ir&&(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 Rt,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 St(e.encoding),this.encoding=e.encoding)}function kt(e){if(!(this instanceof kt))return new kt(e);this._readableState=new xt(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.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,Ct(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&&Ct(e))),function(e,t){t.readingMore||(t.readingMore=!0,ze(Ut,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 Ct(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Mt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?ze(Bt,e):Bt(e))}function Bt(e){Mt("emit readable"),e.emit("readable"),zt(e)}function Ut(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 Nt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,ze(Wt,t,e))}function Wt(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function qt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Mt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Nt(this):Ct(this),null;if(0===(e=Pt(e,t))&&t.ended)return 0===t.length&&Nt(this),null;var n,i=t.needReadable;return Mt("need readable",i),(0===t.length||t.length-e0?Yt(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Nt(this)),null!==n&&this.emit("data",n),n},kt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},kt.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,Mt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){Mt("onunpipe"),e===r&&h()}function s(){Mt("onend"),e.end()}n.endEmitted?ze(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Mt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,zt(e))}}(r);e.on("drain",a);var u=!1;function h(){Mt("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){Mt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==qt(n.pipes,e))&&!u&&(Mt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;Mt("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(){Mt("onfinish"),e.removeListener("close",d),g()}function g(){Mt("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||(Mt("pipe resume"),r.resume()),e},kt.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},Vt.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vt.prototype._writev=null,Vt.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,Xt(e,t),r&&(t.finished?ze(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Xe(ir,kt);for(var tr=Object.keys(Vt.prototype),rr=0;rr()=>{}}))("from-circular-array-stream"),vr=cr.Readable;function yr(r,n){var o,a;if(!(this instanceof yr))return arguments.length>1?new yr(r,n):new yr(r);if(!t(r))throw new TypeError(f("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(o=i({},dr),arguments.length>1&&(a=pr(o,n)))throw a;return gr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),vr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function mr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",r));r=i({},t)}else r={};return r.objectMode=!0,new yr(e,r)}function wr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",e));t=i({},e)}else t={};return r;function r(e){return new yr(e,t)}}o(yr,vr),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._iter||0===this._src.length)return gr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],gr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("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?(gr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(gr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));gr("Closing the stream..."),t.emit("close")})),this)})),e(yr,"objectMode",mr),e(yr,"factory",wr);export{yr as default,wr as factory,mr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7fa6353..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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/string-format';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","iter","isNonNegativeInteger","dir","debug","logger","Readable","require$$0","CircularArrayStream","src","err","this","arguments","length","isCollection","assign","DEFAULTS","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","createStream","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 7cf719a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c5ff2df28fe8f8e46b639fe56d5ac8fbe6cc73aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:30:42 +0000 Subject: [PATCH 092/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 75 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 52 files changed, 4880 insertions(+), 6351 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 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..016566d --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index bfa2a0e..6b2be26 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a circular 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,54 +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-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..9110be7 --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 dc36c001fa1bd73c39cfc88416998b487cf0eb2f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 19:10:59 +0000 Subject: [PATCH 093/138] 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 f811423..dd7dc9e 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-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-circular-array@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.1-esm/index.mjs'; ``` @@ -245,7 +245,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.1-esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 875160ceeb9ba6e2a272471477adf4d52552bae3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 19:11:00 +0000 Subject: [PATCH 094/138] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dd7dc9e..236eeec 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-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-circular-array/tags). For example, + ```javascript import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.1-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-n 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-circular-array@v0.2.1-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; ``` @@ -245,7 +250,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.1-esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; function log( v ) { console.log( v.toString() ); From c5ae780b8a2f33696dd153b1db58e49e4cd0614f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 04:39:13 +0000 Subject: [PATCH 095/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index e402738..13971ea 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 8ffa87274e3842949e47769e1f14385a39c82b69 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 09:06:50 +0000 Subject: [PATCH 096/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 016566d..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 9110be7..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d8afe17a86ee65f18cddd900745b897a467b70d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 09:07:05 +0000 Subject: [PATCH 097/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 53 files changed, 4880 insertions(+), 6354 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 99096d4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T03:22:17.052Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..70c2c54 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 13971ea..6b2be26 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a circular 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-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..6f17406 --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 e271a30634bb72f4d06518ac3a9fe598b59e6b85 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 04:07:12 +0000 Subject: [PATCH 098/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index e402738..13971ea 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 7f008d7d25e8e1ab5b18c9356df57240738e79f8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:46:10 +0000 Subject: [PATCH 099/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 70c2c54..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 6f17406..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b1ab475a7af23c75e08b436d7d5bbb0d2e4828e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:46:22 +0000 Subject: [PATCH 100/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 53 files changed, 4880 insertions(+), 6357 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 e0e3395..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:45:43.270Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..70c2c54 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 13971ea..6b2be26 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a circular 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-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..6f17406 --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 07d8a620a14cab3cc4042932ec5aeb8a9b72745f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 00:18:01 +0000 Subject: [PATCH 101/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index e402738..13971ea 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 d3fcf0df46b45c54cf77a659f86cf412777c1466 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:29:28 +0000 Subject: [PATCH 102/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 70c2c54..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 6f17406..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6ace281c7cec07dfea06fd46bead2e2301e98c09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:29:46 +0000 Subject: [PATCH 103/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 52 files changed, 4880 insertions(+), 6358 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 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..70c2c54 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 13971ea..6b2be26 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a readable stream from a circular 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-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..6f17406 --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 061bc65f8605b7abd6a3b3c7dafe902082a8de94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:28:51 +0000 Subject: [PATCH 104/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index c4f0fb8..e0ab949 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 d30f82ae8161937e6d7bd1e41068f1d3fbf1f0a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:36:18 +0000 Subject: [PATCH 105/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 70c2c54..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.1-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.1-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 6f17406..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cb72309e19d1f35ef33ff29ead6850c1412c28e3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:36:33 +0000 Subject: [PATCH 106/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 52 files changed, 4880 insertions(+), 6562 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 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,SAAY,KACZ,IAAO,KACP,KAAQ,MACR,IAAO,CACR,ICNA,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAgB,QAAS,sCAAuC,EAAE,YAClEC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EA8B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMV,EAAUU,CAAQ,EAGnBT,EAAYS,EAAS,KAAM,IAC/BD,EAAK,IAAMC,EAAQ,IACd,CAACL,EAAUI,EAAK,GAAI,GACjB,IAAI,UAAWF,EAAQ,8DAA+D,MAAOE,EAAK,GAAI,CAAE,EAG5GR,EAAYS,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACR,EAAWO,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HR,EAAYS,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACL,EAAUI,EAAK,QAAS,GAAKA,EAAK,WAAa,MAC7C,IAAI,UAAWF,EAAQ,sEAAuE,WAAYE,EAAK,QAAS,CAAE,EAG9HR,EAAYS,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACP,EAAeM,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG5IR,EAAYS,EAAS,WAAY,IACrCD,EAAK,UAAYC,EAAQ,UACpB,CAACJ,EAAYG,EAAK,SAAU,GACzB,IAAI,UAAWF,EAAQ,gEAAiE,YAAaE,EAAK,SAAU,CAAE,EAG1HR,EAAYS,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACN,EAAsBK,EAAK,IAAK,GAC9B,IAAI,UAAWF,EAAQ,2EAA4E,OAAQE,EAAK,IAAK,CAAE,EAG3HR,EAAYS,EAAS,KAAM,IAC/BD,EAAK,IAAMC,EAAQ,IACdD,EAAK,MAAQ,GAAKA,EAAK,MAAQ,IAC5B,IAAI,UAAWF,EAAQ,wEAAyE,MAAOE,EAAK,GAAI,CAAE,EAGpH,KA5CC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CA6ChH,CAKAX,EAAO,QAAUS,IC/GjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAK1BC,EAAQD,EAAQ,4BAA6B,EAKjDD,EAAO,QAAUE,IChCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,iBAAkB,EAAE,SACxCC,EAAe,QAAS,8BAA+B,EACvDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,uBAAwB,EAC3CC,EAAmB,QAAS,6CAA8C,EAC1EC,EAA2B,QAAS,uDAAwD,EAC5FC,EAAgB,QAAS,4BAA6B,EACtDC,EAAS,QAAS,qBAAsB,EACxCC,EAAW,QAAS,yBAA0B,EAC9CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAW,IACXC,EAAW,IACXC,EAAQ,IAYZ,SAASC,GAAO,CAEf,IAAIC,EACAC,EACAC,EAEJ,GAAK,MAAK,WAIV,IADAF,EAAM,GACEA,GAAM,CAIb,GAHAC,EAAM,KAEN,KAAK,IAAM,EACN,KAAK,GAAK,KAAK,OAAS,KAAK,KAAK,SAAW,EACjD,OAAAH,EAAO,qBAAsB,EACtB,KAAK,KAAM,IAAK,EAExB,KAAK,MAAQ,KAAK,QACb,KAAK,QAAU,GAAK,KAAK,MAAQ,KAAK,KAAK,OAC/C,KAAK,MAAQ,KAAK,KAAK,OACZ,KAAK,QAAU,GAAK,KAAK,KAAO,IAC3C,KAAK,MAAQ,KAAK,KAAK,QAExBI,EAAI,KAAK,KAAM,KAAK,IAAK,EACzBJ,EAAO,gCAAiC,KAAK,UAAWI,CAAE,EAAG,KAAK,KAAM,KAAK,EAAG,EAE3E,KAAK,cAAgB,KACzBA,EAAI,KAAK,WAAYA,CAAE,EAClB,OAAOA,GAAM,SACZ,KAAK,KAAO,EAChBA,EAAIV,EAAeU,CAAE,EAErBA,EAAIV,EAAe,KAAK,KAAKU,CAAE,EAErBf,EAAUe,CAAE,EAClB,KAAK,GAAK,IACdA,EAAIT,EAAO,OAAQ,CAAED,EAAe,KAAK,IAAK,EAAGU,CAAE,CAAE,GAGtDD,EAAM,IAAI,MAAON,EAAQ,yFAA0FO,CAAE,CAAE,GAGpHD,EACJ,KAAK,KAAM,QAASA,CAAI,EAExBD,EAAM,KAAK,KAAME,CAAE,CAErB,CAGD,CASA,SAASC,EAASC,EAAQ,CAEzB,IAAIC,EACJ,GAAK,KAAK,WACT,OAAAP,EAAO,mDAAoD,EACpD,KAER,OAAAO,EAAO,KACP,KAAK,WAAa,GAElBX,EAAUY,CAAM,EAET,KAOP,SAASA,GAAQ,CACXF,IACJN,EAAO,mDAAsDZ,EAASkB,CAAM,EAAMA,EAAM,QAAU,KAAK,UAAWA,CAAM,CAAE,EAC1HC,EAAK,KAAM,QAASD,CAAM,GAE3BN,EAAO,uBAAwB,EAC/BO,EAAK,KAAM,OAAQ,CACpB,CAGD,CA8CA,SAASE,EAAqBC,EAAKC,EAAU,CAC5C,IAAIC,EACAT,EACJ,GAAK,EAAG,gBAAgBM,GACvB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAqBC,EAAKC,CAAQ,EAEvC,IAAIF,EAAqBC,CAAI,EAErC,GAAK,CAACvB,EAAcuB,CAAI,EACvB,MAAM,IAAI,UAAWb,EAAQ,8EAA+Ea,CAAI,CAAE,EAGnH,GADAE,EAAOtB,EAAQ,CAAC,EAAGQ,CAAS,EACvB,UAAU,OAAS,IACvBK,EAAMJ,EAAUa,EAAMD,CAAQ,EACzBR,GACJ,MAAMA,EAIR,OAAAH,EAAO,wEAAyE,KAAK,UAAWY,CAAK,CAAE,EACvG1B,EAAS,KAAM,KAAM0B,CAAK,EAG1BpB,EAAkB,KAAM,aAAc,EAAM,EAG5CC,EAA0B,KAAM,cAAemB,EAAK,UAAW,EAG/DnB,EAA0B,KAAM,OAAQmB,EAAK,GAAI,EAGjDnB,EAA0B,KAAM,aAAcmB,EAAK,WAAa,KAAK,SAAU,EAG/EnB,EAA0B,KAAM,OAAQiB,CAAI,EAG5CjB,EAA0B,KAAM,UAAWmB,EAAK,GAAI,EAGpDnB,EAA0B,KAAM,QAASmB,EAAK,IAAK,EAGnDpB,EAAkB,KAAM,KAAM,CAAE,EAGhCA,EAAkB,KAAM,OAAUoB,EAAK,MAAQ,EAAM,GAAKF,EAAI,MAAO,EAE9D,IACR,CAKAnB,EAASkB,EAAqBvB,CAAS,EAYvCO,EAA0BgB,EAAoB,UAAW,QAASR,CAAK,EAWvER,EAA0BgB,EAAoB,UAAW,UAAWJ,CAAQ,EAK5EpB,EAAO,QAAUwB,IC3QjB,IAAAI,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAsB,IA0C1B,SAASC,EAAYC,EAAKC,EAAU,CACnC,IAAIC,EACJ,GAAK,UAAU,OAAS,EAAI,CAE3B,GADAA,EAAOD,EACF,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWN,EAAQ,qEAAsEM,CAAK,CAAE,EAE3GA,EAAOL,EAAQ,CAAC,EAAGI,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAAA,EAAK,WAAa,GACX,IAAIJ,EAAqBE,EAAKE,CAAK,CAC3C,CAKAR,EAAO,QAAUK,ICrFjB,IAAAI,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAsB,IA4C1B,SAASC,GAASC,EAAU,CAC3B,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAcC,EAAM,CAC5B,OAAO,IAAIL,GAAqBK,EAAKF,CAAK,CAC3C,CACD,CAKAP,EAAO,QAAUK,KCIjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,GAAa,IACbC,GAAU,IAKdH,EAAaC,EAAM,aAAcC,EAAW,EAC5CF,EAAaC,EAAM,UAAWE,EAAQ,EAKtC,OAAO,QAAUF", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..f6fcf79 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index e0ab949..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 a0da048364932a4ab1ec397f8872974de7c1d772 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:38:45 +0000 Subject: [PATCH 107/138] 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 b145858..3bc9958 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-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-circular-array@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.2-esm/index.mjs'; ``` @@ -245,7 +245,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.2-esm/index.mjs'; function log( v ) { console.log( v.toString() ); From 4d34318cbb59c82823647651df5c977c8e97aa04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:38:45 +0000 Subject: [PATCH 108/138] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3bc9958..092bf69 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-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-circular-array/tags). For example, + ```javascript import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.2-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-n 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-circular-array@v0.2.2-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; ``` @@ -245,7 +250,7 @@ This method accepts the same `options` as [`circularArrayStream()`](#circular-ar 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 circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@v0.2.2-esm/index.mjs'; +import circularArrayStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-from-circular-array@esm/index.mjs'; function log( v ) { console.log( v.toString() ); From ec8a124dc51079af602d5b67dd0c8f062e0ab2c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 04:42:07 +0000 Subject: [PATCH 109/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index b796c79..f2b54fd 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 11b9769171e6b7691b46aa6d50e988eccdfc8878 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:51:14 +0000 Subject: [PATCH 110/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f6fcf79..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;oixDA2BIA,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKC,GAClC,IAAIC,EACAC,EACJ,KAAQC,gBAAgBL,IACvB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,GAAqBC,EAAKC,GAE/B,IAAIF,GAAqBC,GAEjC,IAAMO,EAAcP,GACnB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAGvC,GADAE,EAAOQ,EAAQ,GAAIC,IACdN,UAAUC,OAAS,IACvBH,EC1IF,SAAmBD,EAAMD,GACxB,OAAMW,EAAUX,GAGXY,EAAYZ,EAAS,SACzBC,EAAKY,IAAMb,EAAQa,KACbC,EAAUb,EAAKY,MACb,IAAIN,UAAWC,EAAQ,QAAS,MAAOP,EAAKY,MAGhDD,EAAYZ,EAAS,gBACzBC,EAAKc,WAAaf,EAAQe,YACpBC,EAAWf,EAAKc,aACd,IAAIR,UAAWC,EAAQ,QAAS,aAAcP,EAAKc,aAGvDH,EAAYZ,EAAS,cACzBC,EAAKgB,SAAWjB,EAAQiB,UAClBH,EAAUb,EAAKgB,WAAgC,OAAlBhB,EAAKgB,UAChC,IAAIV,UAAWC,EAAQ,QAAS,WAAYP,EAAKgB,WAGrDL,EAAYZ,EAAS,mBACzBC,EAAKiB,cAAgBlB,EAAQkB,eACvBC,EAAelB,EAAKiB,gBAClB,IAAIX,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKiB,gBAG1DN,EAAYZ,EAAS,eACzBC,EAAKmB,UAAYpB,EAAQoB,WACnBC,EAAYpB,EAAKmB,YACf,IAAIb,UAAWC,EAAQ,QAAS,YAAaP,EAAKmB,YAGtDR,EAAYZ,EAAS,UACzBC,EAAKqB,KAAOtB,EAAQsB,MACdC,EAAsBtB,EAAKqB,OACzB,IAAIf,UAAWC,EAAQ,QAAS,OAAQP,EAAKqB,OAGjDV,EAAYZ,EAAS,SACzBC,EAAKuB,IAAMxB,EAAQwB,IACD,IAAbvB,EAAKuB,MAA2B,IAAdvB,EAAKuB,KACpB,IAAIjB,UAAWC,EAAQ,QAAS,MAAOP,EAAKuB,MAG9C,KA5CC,IAAIjB,UAAWC,EAAQ,QAASR,GA6CzC,CD2FQyB,CAAUxB,EAAMD,GACjBE,GACJ,MAAMA,EAkCR,OA9BAR,GAAO,wEAAyEgC,KAAKC,UAAW1B,IAChGL,GAASgC,KAAMzB,KAAMF,GAGrB4B,EAAkB1B,KAAM,cAAc,GAGtC2B,EAA0B3B,KAAM,cAAeF,EAAKc,YAGpDe,EAA0B3B,KAAM,OAAQF,EAAKY,KAG7CiB,EAA0B3B,KAAM,aAAcF,EAAKmB,WAAaM,KAAKC,WAGrEG,EAA0B3B,KAAM,OAAQJ,GAGxC+B,EAA0B3B,KAAM,UAAWF,EAAKuB,KAGhDM,EAA0B3B,KAAM,QAASF,EAAKqB,MAG9CO,EAAkB1B,KAAM,KAAM,GAG9B0B,EAAkB1B,KAAM,OAAuB,IAAbF,EAAKuB,KAAe,EAAIzB,EAAIM,QAEvDF,IACR,CEvKA,SAASY,GAAYhB,EAAKC,GACzB,IAAIC,EACJ,GAAKG,UAAUC,OAAS,EAAI,CAE3B,IAAMM,EADNV,EAAOD,GAEN,MAAM,IAAIO,UAAWC,EAAQ,QAASP,IAEvCA,EAAOQ,EAAQ,GAAIT,EACrB,MACEC,EAAO,CAAA,EAGR,OADAA,EAAKc,YAAa,EACX,IAAIjB,GAAqBC,EAAKE,EACtC,CCXA,SAAS8B,GAAS/B,GACjB,IAAIC,EACJ,GAAKG,UAAUC,OAAS,CACvB,IAAMM,EAAUX,GACf,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvCC,EAAOQ,EAAQ,GAAIT,EACrB,MACEC,EAAO,CAAA,EAER,OAYA,SAAuBF,GACtB,OAAO,IAAID,GAAqBC,EAAKE,EACrC,CACF,CHiJA+B,EAASlC,GAAqBF,IAY9BkC,EAA0BhC,GAAoBmC,UAAW,SA3MzD,WAEC,IAAIC,EACAhC,EACAiC,EAEJ,IAAKhC,KAAKiC,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhC,EAAM,KAENC,KAAKkC,IAAM,EACNlC,KAAKkC,GAAKlC,KAAKmC,OAA8B,IAArBnC,KAAKoC,KAAKlC,OAEtC,OADAX,GAAO,uBACAS,KAAKqC,KAAM,MAEnBrC,KAAKsC,MAAQtC,KAAKuC,QACbvC,KAAKuC,QAAU,GAAKvC,KAAKsC,MAAQtC,KAAKoC,KAAKlC,OAC/CF,KAAKsC,MAAQtC,KAAKoC,KAAKlC,OACZF,KAAKuC,QAAU,GAAKvC,KAAKsC,KAAO,IAC3CtC,KAAKsC,MAAQtC,KAAKoC,KAAKlC,QAExB8B,EAAIhC,KAAKoC,KAAMpC,KAAKsC,MACpB/C,GAAO,gCAAiCgC,KAAKC,UAAWQ,GAAKhC,KAAKsC,KAAMtC,KAAKkC,KAEnD,IAArBlC,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,KAGlDjC,EAAM,IAAIgD,MAAO1C,EAAQ,QAAS2B,KAG/BjC,EACJC,KAAKgD,KAAM,QAASjD,GAEpBgC,EAAM/B,KAAKqC,KAAML,EAElB,CAGF,IAmKAL,EAA0BhC,GAAoBmC,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlD,KAAKiC,YACT1C,GAAO,qDACAS,OAERkD,EAAOlD,KACPA,KAAKiC,YAAa,EAElBkB,GASA,WACMF,IACJ1D,GAAO,mDAAsD6D,EAASH,GAAYA,EAAMI,QAAU9B,KAAKC,UAAWyB,IAClHC,EAAKF,KAAM,QAASC,IAErB1D,GAAO,yBACP2D,EAAKF,KAAM,QACX,IAdMhD,KAiBR,II1BAsD,EAAAC,GAAA,aAAA3C,IACA0C,EAAAC,GAAA,UAAA3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7fe515be2a2d379983024b9a121433c52669ed99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:51:28 +0000 Subject: [PATCH 111/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 138 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 53 files changed, 4880 insertions(+), 6505 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 dc78b73..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T03:22:40.550Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..f6fcf79 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index f2b54fd..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 3a09007595ceba9543b5e5dd8af69c278ff3406d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:35:46 +0000 Subject: [PATCH 112/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index b796c79..f2b54fd 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 a87d305e45e533032b6e284f21f832423c54e185 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:48:46 +0000 Subject: [PATCH 113/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f6fcf79..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ee1fb6b80111e13501317cde30b6e1e36118ecce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:49:01 +0000 Subject: [PATCH 114/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 53 files changed, 4880 insertions(+), 6565 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 145057e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T18:33:08.707Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..f6fcf79 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index f2b54fd..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 4be899b227e7bc165098e4a16534b9cc18509f7b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 04:50:24 +0000 Subject: [PATCH 115/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index c5a345d..ada91cb 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 aa5b2088b759905fe0a337dd1b5319900a947730 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:48:58 +0000 Subject: [PATCH 116/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f6fcf79..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f7615370b2addefe65a60898f005fb88b479f897 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:49:19 +0000 Subject: [PATCH 117/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 53 files changed, 4880 insertions(+), 6565 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 d8748fc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:35:09.935Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..f6fcf79 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ada91cb..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 59c6a1e9b16bf1a8003628d94ba6a6f0b254f11f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 04:59:51 +0000 Subject: [PATCH 118/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index c5a345d..ada91cb 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 8206803f3afbc233b645adbeddde62b063d60cb8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:00:41 +0000 Subject: [PATCH 119/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f6fcf79..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d92f23b23fc26da9c4fe93cf03186a98fc0ed89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:00:56 +0000 Subject: [PATCH 120/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 53 files changed, 4880 insertions(+), 6565 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 3e5f3af..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:45:01.567Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..f6fcf79 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ada91cb..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 0ecc6c899e125f4ab77ebeb05978427e16c9b8d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 04:55:39 +0000 Subject: [PATCH 121/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index c5a345d..ada91cb 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 d5cb2922db48c4acf93dcf35207fd0daff2e1d00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:27:09 +0000 Subject: [PATCH 122/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f6fcf79..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 340caa0e71ef2d6a371d57fa302d88dcadf1e7aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:27:27 +0000 Subject: [PATCH 123/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 -- branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 -- lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 ---- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 53 files changed, 4880 insertions(+), 6565 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 b37206f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:48:16.960Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..f6fcf79 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ada91cb..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 34e1cbe6a1b0f2f11afcfa91e8542a31516f8571 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 05:11:38 +0000 Subject: [PATCH 124/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index cb2d981..2498a0c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 900496721c33c4ea11ca01329c19540570aeb46e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:54:52 +0000 Subject: [PATCH 125/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f6fcf79..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b75496d5f56a6726d9600ea4eb74dc3c1c7a021f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:55:11 +0000 Subject: [PATCH 126/138] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 54 files changed, 4880 insertions(+), 6670 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 d0c0a7f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T03:53:06.076Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 14dba89..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,SAAY,KACZ,IAAO,KACP,KAAQ,MACR,IAAO,CACR,ICNA,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAgB,QAAS,sCAAuC,EAAE,YAClEC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EA8B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMV,EAAUU,CAAQ,EAGnBT,EAAYS,EAAS,KAAM,IAC/BD,EAAK,IAAMC,EAAQ,IACd,CAACL,EAAUI,EAAK,GAAI,GACjB,IAAI,UAAWF,EAAQ,8DAA+D,MAAOE,EAAK,GAAI,CAAE,EAG5GR,EAAYS,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACR,EAAWO,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HR,EAAYS,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACL,EAAUI,EAAK,QAAS,GAAKA,EAAK,WAAa,MAC7C,IAAI,UAAWF,EAAQ,sEAAuE,WAAYE,EAAK,QAAS,CAAE,EAG9HR,EAAYS,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACP,EAAeM,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG5IR,EAAYS,EAAS,WAAY,IACrCD,EAAK,UAAYC,EAAQ,UACpB,CAACJ,EAAYG,EAAK,SAAU,GACzB,IAAI,UAAWF,EAAQ,gEAAiE,YAAaE,EAAK,SAAU,CAAE,EAG1HR,EAAYS,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACN,EAAsBK,EAAK,IAAK,GAC9B,IAAI,UAAWF,EAAQ,2EAA4E,OAAQE,EAAK,IAAK,CAAE,EAG3HR,EAAYS,EAAS,KAAM,IAC/BD,EAAK,IAAMC,EAAQ,IACdD,EAAK,MAAQ,GAAKA,EAAK,MAAQ,IAC5B,IAAI,UAAWF,EAAQ,wEAAyE,MAAOE,EAAK,GAAI,CAAE,EAGpH,KA5CC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CA6ChH,CAKAX,EAAO,QAAUS,IC/GjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAK1BC,EAAQD,EAAQ,4BAA6B,EAKjDD,EAAO,QAAUE,IChCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,iBAAkB,EAAE,SACxCC,EAAe,QAAS,8BAA+B,EACvDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,uBAAwB,EAC3CC,EAAmB,QAAS,6CAA8C,EAC1EC,EAA2B,QAAS,uDAAwD,EAC5FC,EAAgB,QAAS,4BAA6B,EACtDC,EAAS,QAAS,qBAAsB,EACxCC,EAAW,QAAS,yBAA0B,EAC9CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAW,IACXC,EAAW,IACXC,EAAQ,IAYZ,SAASC,GAAO,CAEf,IAAIC,EACAC,EACAC,EAEJ,GAAK,MAAK,WAIV,IADAF,EAAM,GACEA,GAAM,CAIb,GAHAC,EAAM,KAEN,KAAK,IAAM,EACN,KAAK,GAAK,KAAK,OAAS,KAAK,KAAK,SAAW,EACjD,OAAAH,EAAO,qBAAsB,EACtB,KAAK,KAAM,IAAK,EAExB,KAAK,MAAQ,KAAK,QACb,KAAK,QAAU,GAAK,KAAK,MAAQ,KAAK,KAAK,OAC/C,KAAK,MAAQ,KAAK,KAAK,OACZ,KAAK,QAAU,GAAK,KAAK,KAAO,IAC3C,KAAK,MAAQ,KAAK,KAAK,QAExBI,EAAI,KAAK,KAAM,KAAK,IAAK,EACzBJ,EAAO,gCAAiC,KAAK,UAAWI,CAAE,EAAG,KAAK,KAAM,KAAK,EAAG,EAE3E,KAAK,cAAgB,KACzBA,EAAI,KAAK,WAAYA,CAAE,EAClB,OAAOA,GAAM,SACZ,KAAK,KAAO,EAChBA,EAAIV,EAAeU,CAAE,EAErBA,EAAIV,EAAe,KAAK,KAAKU,CAAE,EAErBf,EAAUe,CAAE,EAClB,KAAK,GAAK,IACdA,EAAIT,EAAO,OAAQ,CAAED,EAAe,KAAK,IAAK,EAAGU,CAAE,CAAE,GAGtDD,EAAM,IAAI,MAAON,EAAQ,yFAA0FO,CAAE,CAAE,GAGpHD,EACJ,KAAK,KAAM,QAASA,CAAI,EAExBD,EAAM,KAAK,KAAME,CAAE,CAErB,CAGD,CASA,SAASC,EAASC,EAAQ,CAEzB,IAAIC,EACJ,GAAK,KAAK,WACT,OAAAP,EAAO,mDAAoD,EACpD,KAER,OAAAO,EAAO,KACP,KAAK,WAAa,GAElBX,EAAUY,CAAM,EAET,KAOP,SAASA,GAAQ,CACXF,IACJN,EAAO,mDAAsDZ,EAASkB,CAAM,EAAMA,EAAM,QAAU,KAAK,UAAWA,CAAM,CAAE,EAC1HC,EAAK,KAAM,QAASD,CAAM,GAE3BN,EAAO,uBAAwB,EAC/BO,EAAK,KAAM,OAAQ,CACpB,CAGD,CA8CA,SAASE,EAAqBC,EAAKC,EAAU,CAC5C,IAAIC,EACAT,EACJ,GAAK,EAAG,gBAAgBM,GACvB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAqBC,EAAKC,CAAQ,EAEvC,IAAIF,EAAqBC,CAAI,EAErC,GAAK,CAACvB,EAAcuB,CAAI,EACvB,MAAM,IAAI,UAAWb,EAAQ,8EAA+Ea,CAAI,CAAE,EAGnH,GADAE,EAAOtB,EAAQ,CAAC,EAAGQ,CAAS,EACvB,UAAU,OAAS,IACvBK,EAAMJ,EAAUa,EAAMD,CAAQ,EACzBR,GACJ,MAAMA,EAIR,OAAAH,EAAO,wEAAyE,KAAK,UAAWY,CAAK,CAAE,EACvG1B,EAAS,KAAM,KAAM0B,CAAK,EAG1BpB,EAAkB,KAAM,aAAc,EAAM,EAG5CC,EAA0B,KAAM,cAAemB,EAAK,UAAW,EAG/DnB,EAA0B,KAAM,OAAQmB,EAAK,GAAI,EAGjDnB,EAA0B,KAAM,aAAcmB,EAAK,WAAa,KAAK,SAAU,EAG/EnB,EAA0B,KAAM,OAAQiB,CAAI,EAG5CjB,EAA0B,KAAM,UAAWmB,EAAK,GAAI,EAGpDnB,EAA0B,KAAM,QAASmB,EAAK,IAAK,EAGnDpB,EAAkB,KAAM,KAAM,CAAE,EAGhCA,EAAkB,KAAM,OAAUoB,EAAK,MAAQ,EAAM,GAAKF,EAAI,MAAO,EAE9D,IACR,CAKAnB,EAASkB,EAAqBvB,CAAS,EAYvCO,EAA0BgB,EAAoB,UAAW,QAASR,CAAK,EAWvER,EAA0BgB,EAAoB,UAAW,UAAWJ,CAAQ,EAK5EpB,EAAO,QAAUwB,IC3QjB,IAAAI,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAsB,IA0C1B,SAASC,EAAYC,EAAKC,EAAU,CACnC,IAAIC,EACJ,GAAK,UAAU,OAAS,EAAI,CAE3B,GADAA,EAAOD,EACF,CAACN,EAAUO,CAAK,EACpB,MAAM,IAAI,UAAWN,EAAQ,qEAAsEM,CAAK,CAAE,EAE3GA,EAAOL,EAAQ,CAAC,EAAGI,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAAA,EAAK,WAAa,GACX,IAAIJ,EAAqBE,EAAKE,CAAK,CAC3C,CAKAR,EAAO,QAAUK,ICrFjB,IAAAI,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAsB,IA4C1B,SAASC,GAASC,EAAU,CAC3B,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAcC,EAAM,CAC5B,OAAO,IAAIL,GAAqBK,EAAKF,CAAK,CAC3C,CACD,CAKAP,EAAO,QAAUK,KCIjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,GAAa,IACbC,GAAU,IAKdH,EAAaC,EAAM,aAAcC,EAAW,EAC5CF,EAAaC,EAAM,UAAWE,EAAQ,EAKtC,OAAO,QAAUF", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..f6fcf79 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2498a0c..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 d11876d5a7f638144ca49569ed19314b34af8ec1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:01:25 +0000 Subject: [PATCH 127/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index cb2d981..2498a0c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 16cfc1c01e28fcf136696fd7a48bf9bee62e83c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:17:52 +0000 Subject: [PATCH 128/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f6fcf79..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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 97dfe1272ed83ccc6e74667faad8091220a93317 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:18:14 +0000 Subject: [PATCH 129/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 54 files changed, 4880 insertions(+), 6673 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 2ff401a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T00:57:10.008Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 463f20b..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..24ea12f --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2498a0c..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 0b17cef90190b7da6e60e68f7f9bbc07cc344ef8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 00:36:59 +0000 Subject: [PATCH 130/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index cb2d981..2498a0c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 21196cb488aae010d9a5736d254214cbe8e47af7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 00:44:23 +0000 Subject: [PATCH 131/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 24ea12f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_idx","_stride","_objectMode","_serialize","string2buffer","_sep","isBuffer","Buffer","concat","Error","emit","error","self","nextTick","isError","message","setReadOnly","main"],"mappings":";;oixDA2BIA,wDAAQC,CAAQ,8BCLhBC,GAAWC,GAA6BD,SAiK5C,SAASE,GAAqBC,EAAKC,GAClC,IAAIC,EACAC,EACJ,KAAQC,gBAAgBL,IACvB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,GAAqBC,EAAKC,GAE/B,IAAIF,GAAqBC,GAEjC,IAAMO,EAAcP,GACnB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAGvC,GADAE,EAAOQ,EAAQ,GAAIC,IACdN,UAAUC,OAAS,IACvBH,EC1IF,SAAmBD,EAAMD,GACxB,OAAMW,EAAUX,GAGXY,EAAYZ,EAAS,SACzBC,EAAKY,IAAMb,EAAQa,KACbC,EAAUb,EAAKY,MACb,IAAIN,UAAWC,EAAQ,QAAS,MAAOP,EAAKY,MAGhDD,EAAYZ,EAAS,gBACzBC,EAAKc,WAAaf,EAAQe,YACpBC,EAAWf,EAAKc,aACd,IAAIR,UAAWC,EAAQ,QAAS,aAAcP,EAAKc,aAGvDH,EAAYZ,EAAS,cACzBC,EAAKgB,SAAWjB,EAAQiB,UAClBH,EAAUb,EAAKgB,WAAgC,OAAlBhB,EAAKgB,UAChC,IAAIV,UAAWC,EAAQ,QAAS,WAAYP,EAAKgB,WAGrDL,EAAYZ,EAAS,mBACzBC,EAAKiB,cAAgBlB,EAAQkB,eACvBC,EAAelB,EAAKiB,gBAClB,IAAIX,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKiB,gBAG1DN,EAAYZ,EAAS,eACzBC,EAAKmB,UAAYpB,EAAQoB,WACnBC,EAAYpB,EAAKmB,YACf,IAAIb,UAAWC,EAAQ,QAAS,YAAaP,EAAKmB,YAGtDR,EAAYZ,EAAS,UACzBC,EAAKqB,KAAOtB,EAAQsB,MACdC,EAAsBtB,EAAKqB,OACzB,IAAIf,UAAWC,EAAQ,QAAS,OAAQP,EAAKqB,OAGjDV,EAAYZ,EAAS,SACzBC,EAAKuB,IAAMxB,EAAQwB,IACD,IAAbvB,EAAKuB,MAA2B,IAAdvB,EAAKuB,KACpB,IAAIjB,UAAWC,EAAQ,QAAS,MAAOP,EAAKuB,MAG9C,KA5CC,IAAIjB,UAAWC,EAAQ,QAASR,GA6CzC,CD2FQyB,CAAUxB,EAAMD,GACjBE,GACJ,MAAMA,EAkCR,OA9BAR,GAAO,wEAAyEgC,KAAKC,UAAW1B,IAChGL,GAASgC,KAAMzB,KAAMF,GAGrB4B,EAAkB1B,KAAM,cAAc,GAGtC2B,EAA0B3B,KAAM,cAAeF,EAAKc,YAGpDe,EAA0B3B,KAAM,OAAQF,EAAKY,KAG7CiB,EAA0B3B,KAAM,aAAcF,EAAKmB,WAAaM,KAAKC,WAGrEG,EAA0B3B,KAAM,OAAQJ,GAGxC+B,EAA0B3B,KAAM,UAAWF,EAAKuB,KAGhDM,EAA0B3B,KAAM,QAASF,EAAKqB,MAG9CO,EAAkB1B,KAAM,KAAM,GAG9B0B,EAAkB1B,KAAM,OAAuB,IAAbF,EAAKuB,KAAe,EAAIzB,EAAIM,QAEvDF,IACR,CEvKA,SAASY,GAAYhB,EAAKC,GACzB,IAAIC,EACJ,GAAKG,UAAUC,OAAS,EAAI,CAE3B,IAAMM,EADNV,EAAOD,GAEN,MAAM,IAAIO,UAAWC,EAAQ,QAASP,IAEvCA,EAAOQ,EAAQ,GAAIT,EACrB,MACEC,EAAO,CAAA,EAGR,OADAA,EAAKc,YAAa,EACX,IAAIjB,GAAqBC,EAAKE,EACtC,CCXA,SAAS8B,GAAS/B,GACjB,IAAIC,EACJ,GAAKG,UAAUC,OAAS,CACvB,IAAMM,EAAUX,GACf,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvCC,EAAOQ,EAAQ,GAAIT,EACrB,MACEC,EAAO,CAAA,EAER,OAYA,SAAuBF,GACtB,OAAO,IAAID,GAAqBC,EAAKE,EACrC,CACF,CHiJA+B,EAASlC,GAAqBF,IAY9BkC,EAA0BhC,GAAoBmC,UAAW,SA3MzD,WAEC,IAAIC,EACAhC,EACAiC,EAEJ,IAAKhC,KAAKiC,WAIV,IADAF,GAAM,EACEA,GAAM,CAIb,GAHAhC,EAAM,KAENC,KAAKkC,IAAM,EACNlC,KAAKkC,GAAKlC,KAAKmC,OAA8B,IAArBnC,KAAKoC,KAAKlC,OAEtC,OADAX,GAAO,uBACAS,KAAKqC,KAAM,MAEnBrC,KAAKsC,MAAQtC,KAAKuC,QACbvC,KAAKuC,QAAU,GAAKvC,KAAKsC,MAAQtC,KAAKoC,KAAKlC,OAC/CF,KAAKsC,MAAQtC,KAAKoC,KAAKlC,OACZF,KAAKuC,QAAU,GAAKvC,KAAKsC,KAAO,IAC3CtC,KAAKsC,MAAQtC,KAAKoC,KAAKlC,QAExB8B,EAAIhC,KAAKoC,KAAMpC,KAAKsC,MACpB/C,GAAO,gCAAiCgC,KAAKC,UAAWQ,GAAKhC,KAAKsC,KAAMtC,KAAKkC,KAEnD,IAArBlC,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,KAGlDjC,EAAM,IAAIgD,MAAO1C,EAAQ,QAAS2B,KAG/BjC,EACJC,KAAKgD,KAAM,QAASjD,GAEpBgC,EAAM/B,KAAKqC,KAAML,EAElB,CAGF,IAmKAL,EAA0BhC,GAAoBmC,UAAW,WA1JzD,SAAkBmB,GAEjB,IAAIC,EACJ,OAAKlD,KAAKiC,YACT1C,GAAO,qDACAS,OAERkD,EAAOlD,KACPA,KAAKiC,YAAa,EAElBkB,GASA,WACMF,IACJ1D,GAAO,mDAAsD6D,EAASH,GAAYA,EAAMI,QAAU9B,KAAKC,UAAWyB,IAClHC,EAAKF,KAAM,QAASC,IAErB1D,GAAO,yBACP2D,EAAKF,KAAM,QACX,IAdMhD,KAiBR,II1BAsD,EAAAC,GAAA,aAAA3C,IACA0C,EAAAC,GAAA,UAAA3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8f4f52af247da3ea98fede485f1ffac08f94efaa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 00:44:48 +0000 Subject: [PATCH 132/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 54 files changed, 4880 insertions(+), 6673 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 41f7215..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-10T00:34:28.748Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 463f20b..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..24ea12f --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2498a0c..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 1a01123efd4c7811663f0a494f6d51d684707693 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 00:59:53 +0000 Subject: [PATCH 133/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index cb2d981..2498a0c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 55dd904c1e09440617db197261eed3494895d28e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:48:04 +0000 Subject: [PATCH 134/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 24ea12f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f98ab3e686068cfd0159db6d82138c13a8f3df5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:48:23 +0000 Subject: [PATCH 135/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 54 files changed, 4880 insertions(+), 6673 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 f7b9d2d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-07T00:54:20.892Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 463f20b..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..24ea12f --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2498a0c..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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 8de50bd52ba101a4fa29df1b703a10f3afd5a4e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:39:31 +0000 Subject: [PATCH 136/138] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 6 +++--- lib/object_mode.js | 4 ++-- lib/validate.js | 18 +++++++++--------- package.json | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 6bfd8f3..79b247d 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 CircularArrayStream = require( './main.js' ); @@ -71,7 +71,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( '1MB2V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index f2cd20f..2a6ea3a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -31,7 +31,7 @@ var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read var string2buffer = require( '@stdlib/buffer-from-string' ); var Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg var nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var DEFAULTS = require( './defaults.json' ); var validate = require( './validate.js' ); var debug = require( './debug.js' ); @@ -86,7 +86,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( '1MBA9', v ) ); } } if ( err ) { @@ -191,7 +191,7 @@ function CircularArrayStream( src, options ) { return new CircularArrayStream( src ); } if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); + throw new TypeError( format( '1MB2O', src ) ); } opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { diff --git a/lib/object_mode.js b/lib/object_mode.js index ecb84cb..417c37f 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 CircularArrayStream = require( './main.js' ); @@ -70,7 +70,7 @@ function objectMode( src, options ) { if ( arguments.length > 1 ) { opts = options; if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); + throw new TypeError( format( '1MB2V', opts ) ); } opts = assign( {}, options ); } else { diff --git a/lib/validate.js b/lib/validate.js index 9372d68..5bbc36f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitiv var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 // @@ -59,48 +59,48 @@ 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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) ); } } if ( hasOwnProp( options, 'iter' ) ) { opts.iter = options.iter; if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) ); + return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); } } if ( hasOwnProp( options, 'dir' ) ) { opts.dir = options.dir; if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) ); + return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); } } return null; diff --git a/package.json b/package.json index cb2d981..2498a0c 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,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 13495b5b3f076a30158b36137f441a3fa815936b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:42:58 +0000 Subject: [PATCH 137/138] Remove files --- index.d.ts | 315 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5162 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 7c4f28f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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; - - /** - * Number of iterations (default: `1e308`). - */ - iter?: number; - - /** - * Iteration direction (default: `1`). - */ - dir?: number; -} - -/** -* 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 which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var CircularArrayStream = circularArrayStream; - * var stream = new CircularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - new( src: Collection, options?: Options ): Readable; // newable - - /** - * Stream constructor for generating a readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream( arr, opts ); - * - * stream.pipe( inspectStream( log ) ); - */ - ( src: Collection, options?: Options ): Readable; // callable - - /** - * Returns a function for creating readable streams from circular array-like objects. - * - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 = circularArrayStream.factory( opts ); - * - * // Create 10 identically configured streams... - * var streams = []; - * for ( i = 0; i < 10; i++ ) { - * streams.push( createStream( arr ) ); - * } - */ - factory( options?: Options ): ( src: Collection ) => Readable; - - /** - * Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. - * - * @param src - source array-like object - * @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 - * @param options.iter - number of iterations (default: 1e308) - * @param options.dir - iteration direction (default: 1) - * @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 opts = { - * 'iter': arr.length * 2 - * }; - * - * var stream = circularArrayStream.objectMode( arr, opts ); - * - * stream.pipe( inspectStream.objectMode( log ) ); - */ - objectMode( src: Collection, options?: Options ): Readable; -} - -/** -* Creates a readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param src - source array-like object -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var CircularArrayStream = circularArrayStream; -* var stream = new CircularArrayStream( arr, opts ); -* -* 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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -declare var circularArrayStream: Constructor; - - -// EXPORTS // - -export = circularArrayStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 24ea12f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29b4469..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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 a6d9f2f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 52deaf4e7653d75ff15602d1c3c4d52250030be3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:43:17 +0000 Subject: [PATCH 138/138] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 198 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 97 - benchmark/benchmark.throughput.js | 257 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 13 - dist/index.js.map | 7 - docs/repl.txt | 163 - docs/types/test.ts | 92 - examples/index.js | 52 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 33 - lib/defaults.json | 7 - lib/factory.js | 100 - lib/index.js | 118 - lib/main.js | 268 - lib/object_mode.js | 86 - lib/validate.js | 112 - package.json | 76 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 192 - test/test.js | 43 - test/test.main.js | 850 --- test/test.object_mode.js | 194 - test/test.validate.js | 302 -- 54 files changed, 4880 insertions(+), 6673 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 3184a7c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T00:38:14.642Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 463f20b..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-circular-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 7d4ef6a..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-circular-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 e197763..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: '34 22 * * 2' - - # 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 + + ```
@@ -312,7 +309,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]. @@ -383,11 +380,11 @@ 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 -[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator +[@stdlib/streams/node/from-iterator]: https://github.com/stdlib-js/streams-node-from-iterator/tree/esm -[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-array +[@stdlib/streams/node/from-strided-array]: https://github.com/stdlib-js/streams-node-from-strided-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 8ee1fad..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 circularArrayStream = 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 = circularArrayStream( arr ); - 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 = circularArrayStream.objectMode( arr ); - 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 = circularArrayStream.factory(); - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = createStream( arr ); - 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 94d6c5d..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 circularArrayStream = 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = {}; - rStream = circularArrayStream.objectMode( arr, 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 = [ 1, 2, 3 ]; - - // Create a source stream: - opts = { - 'highWaterMark': 0 - }; - rStream = circularArrayStream.objectMode( arr, 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 c5e8c66..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-circular-array" -%% click B href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/from-circular-array -[production-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-from-circular-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-from-circular-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-from-circular-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 8346e90..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import circularArrayStream from '../docs/types/index'; -export = circularArrayStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4444381..0000000 --- a/dist/index.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=u(function(ue,T){T.exports={objectMode:!1,encoding:null,sep:"\n",iter:1e308,dir:1}});var b=u(function(oe,m){ -var S=require('@stdlib/assert-is-plain-object/dist'),n=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,C=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return S(r)?n(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1MB2W',"sep",e.sep)):n(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1MB2o',"objectMode",e.objectMode)):n(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1MB7n',"encoding",e.encoding)):n(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!N(e.highWaterMark))?new TypeError(t('1MB4k',"highWaterMark",e.highWaterMark)):n(r,"serialize")&&(e.serialize=r.serialize,!C(e.serialize))?new TypeError(t('1MB6p',"serialize",e.serialize)):n(r,"iter")&&(e.iter=r.iter,!k(e.iter))?new TypeError(t('1MB2t',"iter",e.iter)):n(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1MB2v',"dir",e.dir)):null:new TypeError(t('1MB2V',r));}m.exports=V -});var _=u(function(de,y){ -var W=require("debug"),A=W("from-circular-array-stream");y.exports=A -});var l=u(function(le,w){ -var q=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),P=require('@stdlib/assert-is-error/dist'),B=require('@stdlib/assert-is-buffer/dist'),J=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),h=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/buffer-from-string/dist'),I=require('@stdlib/buffer-ctor/dist'),L=require('@stdlib/utils-next-tick/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),D=c(),G=b(),o=_();function U(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._iter||this._src.length===0)return o("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=f(i):i=f(this._sep+i):B(i)?this._i>1&&(i=I.concat([f(this._sep),i])):r=new Error(p('1MBA9',i))),r?this.emit("error",r):e=this.push(i)}}function H(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,L(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",P(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function s(e,r){var i,d;if(!(this instanceof s))return arguments.length>1?new s(e,r):new s(e);if(!F(e))throw new TypeError(p('1MB2O',e));if(i=J({},D),arguments.length>1&&(d=G(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),q.call(this,i),h(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),a(this,"_iter",i.iter),h(this,"_i",0),h(this,"_idx",i.dir===1?-1:e.length),this}R(s,q);a(s.prototype,"_read",U);a(s.prototype,"destroy",H);w.exports=s -});var M=u(function(he,j){ -var K=require('@stdlib/assert-is-plain-object/dist'),Q=require('@stdlib/error-tools-fmtprodmsg/dist'),X=require('@stdlib/object-assign/dist'),Y=l();function Z(e,r){var i;if(arguments.length>1){if(i=r,!K(i))throw new TypeError(Q('1MB2V',i));i=X({},r)}else i={};return i.objectMode=!0,new Y(e,i)}j.exports=Z -});var E=u(function(fe,O){ -var $=require('@stdlib/assert-is-plain-object/dist'),ee=require('@stdlib/error-tools-fmtprodmsg/dist'),re=require('@stdlib/object-assign/dist'),ie=l();function te(e){var r;if(arguments.length){if(!$(e))throw new TypeError(ee('1MB2V',e));r=re({},e)}else r={};return i;function i(d){return new ie(d,r)}}O.exports=te -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),ae=M(),ne=E();x(v,"objectMode",ae);x(v,"factory",ne);module.exports=v; -/** @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 4faa122..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\t\"iter\": 1e308,\n\t\"dir\": 1\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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\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-circular-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 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 nextTick = require( '@stdlib/utils-next-tick' );\nvar format = require( '@stdlib/string-format' );\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = CircularArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\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 CircularArrayStream( src, 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 CircularArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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", "isNonNegativeInteger", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "format", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "CircularArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "CircularArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index b02e202..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,163 +0,0 @@ - -{{alias}}( src[, options] ) - Creates a readable stream from an array-like object which repeatedly - iterates over the provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream. - - Examples - -------- - > function fcn( chunk ) { console.log( chunk.toString() ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}( [ 1, 2, 3 ], opts ); - > 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 - which repeatedly iterate over the elements of provided values. - - 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". - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - fcn: Function - Function for creating readable streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( src[, options] ) - Returns an "objectMode" readable stream from an array-like object which - repeatedly iterates over a provided value's elements. - - 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 - ---------- - src: ArrayLikeObject - Source value. - - 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. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, a stream iterates over elements - from right-to-left. Default: 1. - - Returns - ------- - stream: ReadableStream - Readable stream operating in "objectMode". - - Examples - -------- - > function fcn( v ) { console.log( v ); }; - > var opts = { 'iter': 15 }; - > var s = {{alias}}.objectMode( [ 1, 2, 3 ], opts ); - > 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 c3903a4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 CircularArrayStream = require( './index' ); - - -// TESTS // - -// The constructor returns a stream... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - new CircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor is callable... -{ - const circularCircularArrayStream = CircularArrayStream; - circularCircularArrayStream( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - circularCircularArrayStream( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has an `objectMode` method which returns a stream... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], { 'objectMode': true } ); // $ExpectType Readable -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - const f = CircularArrayStream.factory(); - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable - f( [ 5, 6, 7, 8 ] ); // $ExpectType Readable - f( [ 1, 2, 3, 4 ] ); // $ExpectType Readable -} - -// The compiler throws an error if the constructor is provided a second argument which is not an options object... -{ - new CircularArrayStream( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], true ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], false ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], [] ); // $ExpectError - new CircularArrayStream( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a second argument which is not an options object... -{ - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], true ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], false ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], [] ); // $ExpectError - CircularArrayStream.objectMode( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - CircularArrayStream.factory( 'abc' ); // $ExpectError - CircularArrayStream.factory( 123 ); // $ExpectError - CircularArrayStream.factory( true ); // $ExpectError - CircularArrayStream.factory( false ); // $ExpectError - CircularArrayStream.factory( [] ); // $ExpectError - CircularArrayStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f2 = CircularArrayStream.factory(); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError - - f2 = CircularArrayStream.factory( { 'objectMode': true } ); - f2(); // $ExpectError - f2( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ce16ab6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -var randu = require( '@stdlib/random-base-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var circularArrayStream = require( './../lib' ); - -function log( v ) { - console.log( v.toString() ); -} - -// Create an array containing uniformly distributed pseudorandom numbers: -var arr = new Float64Array( 10 ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu(); -} - -// Convert the array to a stream: -var opts = { - 'objectMode': true, - 'iter': arr.length * 3 -}; -var stream = circularArrayStream( arr, 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 6541c0d..7c4f28f 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..24ea12f --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-string@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-ctor@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-next-tick@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as d}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import{isPrimitive as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";function w(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 m(){}function b(){b.init.call(this)}function _(e){return void 0===e._maxListeners?b.defaultMaxListeners:e._maxListeners}function E(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 m,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))&&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 R(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 j(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 S(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}m.prototype=Object.create(null),b.EventEmitter=b,b.usingDomains=!1,b.prototype.domain=void 0,b.prototype._events=void 0,b.prototype._maxListeners=void 0,b.defaultMaxListeners=10,b.init=function(){this.domain=null,b.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new m,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.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},b.prototype.getMaxListeners=function(){return _(this)},b.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=S(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 m,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var M="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A=[],L=[],T="undefined"!=typeof Uint8Array?Uint8Array:Array,x=!1;function k(){x=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)A[t]=e[t],L[e.charCodeAt(t)]=t;L["-".charCodeAt(0)]=62,L["_".charCodeAt(0)]=63}function P(e,t,r){for(var n,i,o=[],s=t;s>18&63]+A[i>>12&63]+A[i>>6&63]+A[63&i]);return o.join("")}function B(e){var t;x||k();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+=A[t>>2],i+=A[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=A[t>>10],i+=A[t>>4&63],i+=A[t<<2&63],i+="="),o.push(i),o.join("")}function C(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 O(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 U={}.toString,D=Array.isArray||function(e){return"[object Array]"==U.call(e)};function I(){return Y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function z(e,t){if(I()=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|e}function J(e){return!(null==e||!e._isBuffer)}function V(e,t){if(J(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 be(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return _e(e).length;default:if(n)return be(e).length;t=(""+t).toLowerCase(),n=!0}}function $(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 he(this,t,r);case"utf8":case"utf-8":return oe(this,t,r);case"ascii":return ae(this,t,r);case"latin1":case"binary":return ue(this,t,r);case"base64":return ie(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fe(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function G(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Z(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=Y.from(t,n)),J(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,Y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(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 ie(e,t,r){return 0===t&&r===e.length?B(e):B(e.slice(t,r))}function oe(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<=se)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+=" ... ")),""},Y.prototype.compare=function(e,t,r,n,i){if(!J(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 Q(this,e,t,r);case"utf8":case"utf-8":return X(this,e,t,r);case"ascii":return ee(this,e,t,r);case"latin1":case"binary":return te(this,e,t,r);case"base64":return re(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ne(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var se=4096;function ae(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 ce(e,t,r,n,i,o){if(!J(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function de(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 pe(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 ge(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 ve(e,t,r,n,i){return i||ge(e,0,r,4),O(e,t,r,n,23,4),r+4}function ye(e,t,r,n,i){return i||ge(e,0,r,8),O(e,t,r,n,52,8),r+8}Y.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},Y.prototype.readUInt8=function(e,t){return t||le(e,1,this.length),this[e]},Y.prototype.readUInt16LE=function(e,t){return t||le(e,2,this.length),this[e]|this[e+1]<<8},Y.prototype.readUInt16BE=function(e,t){return t||le(e,2,this.length),this[e]<<8|this[e+1]},Y.prototype.readUInt32LE=function(e,t){return t||le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Y.prototype.readUInt32BE=function(e,t){return t||le(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Y.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||le(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Y.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||le(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},Y.prototype.readInt8=function(e,t){return t||le(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Y.prototype.readInt16LE=function(e,t){t||le(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt16BE=function(e,t){t||le(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Y.prototype.readInt32LE=function(e,t){return t||le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Y.prototype.readInt32BE=function(e,t){return t||le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Y.prototype.readFloatLE=function(e,t){return t||le(e,4,this.length),C(this,e,!0,23,4)},Y.prototype.readFloatBE=function(e,t){return t||le(e,4,this.length),C(this,e,!1,23,4)},Y.prototype.readDoubleLE=function(e,t){return t||le(e,8,this.length),C(this,e,!0,52,8)},Y.prototype.readDoubleBE=function(e,t){return t||le(e,8,this.length),C(this,e,!1,52,8)},Y.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||ce(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},Y.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,255,0),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Y.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,65535,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):pe(this,e,t,!0),t+4},Y.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,4294967295,0),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);ce(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},Y.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,1,127,-128),Y.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Y.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):de(this,e,t,!0),t+2},Y.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,2,32767,-32768),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):de(this,e,t,!1),t+2},Y.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),Y.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):pe(this,e,t,!0),t+4},Y.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||ce(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Y.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):pe(this,e,t,!1),t+4},Y.prototype.writeFloatLE=function(e,t,r){return ve(this,e,t,!0,r)},Y.prototype.writeFloatBE=function(e,t,r){return ve(this,e,t,!1,r)},Y.prototype.writeDoubleLE=function(e,t,r){return ye(this,e,t,!0,r)},Y.prototype.writeDoubleBE=function(e,t,r){return ye(this,e,t,!1,r)},Y.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||!Y.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 _e(e){return function(e){var t,r,n,i,o,s;x||k();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 T(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(we,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Ee(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Re(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function je(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Me=je,Ae=Se;function Le(e){if(Me===setTimeout)return setTimeout(e,0);if((Me===je||!Me)&&setTimeout)return Me=setTimeout,setTimeout(e,0);try{return Me(e,0)}catch(t){try{return Me.call(null,e,0)}catch(t){return Me.call(this,e,0)}}}"function"==typeof M.setTimeout&&(Me=setTimeout),"function"==typeof M.clearTimeout&&(Ae=clearTimeout);var Te,xe=[],ke=!1,Pe=-1;function Be(){ke&&Te&&(ke=!1,Te.length?xe=Te.concat(xe):Pe=-1,xe.length&&Ce())}function Ce(){if(!ke){var e=Le(Be);ke=!0;for(var t=xe.length;t;){for(Te=xe,xe=[];++Pe1)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]),at(t)?r.showHidden=t:t&&function(e,t){if(!t||!ct(t))return e;var r=Object.keys(t),n=r.length;for(;n--;)e[r[n]]=t[r[n]]}(r,t),ft(r.showHidden)&&(r.showHidden=!1),ft(r.depth)&&(r.depth=2),ft(r.colors)&&(r.colors=!1),ft(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=rt),it(r,e,r.depth)}function rt(e,t){var r=tt.styles[t];return r?"["+tt.colors[r][0]+"m"+e+"["+tt.colors[r][1]+"m":e}function nt(e,t){return e}function it(e,t,r){if(e.customInspect&&t&>(t.inspect)&&t.inspect!==tt&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return ht(n)||(n=it(e,n,r)),n}var i=function(e,t){if(ft(t))return e.stylize("undefined","undefined");if(ht(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(at(t))return e.stylize(""+t,"boolean");if(ut(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)),pt(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return ot(t);if(0===o.length){if(gt(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(lt(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(dt(t))return e.stylize(Date.prototype.toString.call(t),"date");if(pt(t))return ot(t)}var u,h,f="",l=!1,c=["{","}"];(u=t,Array.isArray(u)&&(l=!0,c=["[","]"]),gt(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return lt(t)&&(f=" "+RegExp.prototype.toString.call(t)),dt(t)&&(f=" "+Date.prototype.toUTCString.call(t)),pt(t)&&(f=" "+ot(t)),0!==o.length||l&&0!=t.length?r<0?lt(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 ot(e){return"["+Error.prototype.toString.call(e)+"]"}function st(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")),yt(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=ut(r)?it(e,u.value,null):it(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")),ft(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 at(e){return"boolean"==typeof e}function ut(e){return null===e}function ht(e){return"string"==typeof e}function ft(e){return void 0===e}function lt(e){return ct(e)&&"[object RegExp]"===vt(e)}function ct(e){return"object"==typeof e&&null!==e}function dt(e){return ct(e)&&"[object Date]"===vt(e)}function pt(e){return ct(e)&&("[object Error]"===vt(e)||e instanceof Error)}function gt(e){return"function"==typeof e}function vt(e){return Object.prototype.toString.call(e)}function yt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function wt(){this.head=null,this.tail=null,this.length=0}tt.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]},tt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},wt.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},wt.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},wt.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}},wt.prototype.clear=function(){this.head=this.tail=null,this.length=0},wt.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},wt.prototype.concat=function(e){if(0===this.length)return Y.alloc(0);if(1===this.length)return this.head.data;for(var t=Y.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var mt=Y.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 bt(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!mt(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=Et;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Rt;break;default:return void(this.write=_t)}this.charBuffer=new Y(6),this.charReceived=0,this.charLength=0}function _t(e){return e.toString(this.encoding)}function Et(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Rt(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}bt.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},bt.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},bt.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},Mt.ReadableState=St;var jt=function(e){if(ft(Xe)&&(Xe=$e.env.NODE_DEBUG||""),e=e.toUpperCase(),!et[e])if(new RegExp("\\b"+e+"\\b","i").test(Xe)){et[e]=function(){var t=Ke.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else et[e]=function(){};return et[e]}("stream");function St(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof er&&(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 wt,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 bt(e.encoding),this.encoding=e.encoding)}function Mt(e){if(!(this instanceof Mt))return new Mt(e);this._readableState=new St(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),b.call(this)}function At(e,t,r,n,i){var o=function(e,t){var r=null;Y.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,Oe(Pt,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||(jt("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?Oe(kt,e):kt(e))}function kt(e){jt("emit readable"),e.emit("readable"),Ot(e)}function Pt(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=Y.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 Dt(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,Oe(It,t,e))}function It(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zt(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return jt("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Dt(this):xt(this),null;if(0===(e=Tt(e,t))&&t.ended)return 0===t.length&&Dt(this),null;var n,i=t.needReadable;return jt("need readable",i),(0===t.length||t.length-e0?Ut(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Dt(this)),null!==n&&this.emit("data",n),n},Mt.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Mt.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,jt("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:h;function o(e){jt("onunpipe"),e===r&&h()}function s(){jt("onend"),e.end()}n.endEmitted?Oe(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;jt("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ot(e))}}(r);e.on("drain",a);var u=!1;function h(){jt("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){jt("ondata"),f=!1,!1!==e.write(t)||f||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zt(n.pipes,e))&&!u&&(jt("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function c(t){var r;jt("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(){jt("onfinish"),e.removeListener("close",d),g()}function g(){jt("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||(jt("pipe resume"),r.resume()),e},Mt.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},qt.prototype._write=function(e,t,r){r(new Error("not implemented"))},qt.prototype._writev=null,qt.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,Gt(e,t),r&&(t.finished?Oe(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Ge(er,Mt);for(var Kt=Object.keys(qt.prototype),Qt=0;Qt()=>{}}))("from-circular-array-stream"),lr=ur.Readable;function cr(r,n){var o,a;if(!(this instanceof cr))return arguments.length>1?new cr(r,n):new cr(r);if(!t(r))throw new TypeError(f("1MB2O",r));if(o=i({},hr),arguments.length>1&&(a=function(e,t){return l(t)?c(t,"sep")&&(e.sep=t.sep,!v(e.sep))?new TypeError(f("1MB2W","sep",e.sep)):c(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(f("1MB2o","objectMode",e.objectMode)):c(t,"encoding")&&(e.encoding=t.encoding,!v(e.encoding)&&null!==e.encoding)?new TypeError(f("1MB7n","encoding",e.encoding)):c(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!p(e.highWaterMark))?new TypeError(f("1MB4k","highWaterMark",e.highWaterMark)):c(t,"serialize")&&(e.serialize=t.serialize,!y(e.serialize))?new TypeError(f("1MB6p","serialize",e.serialize)):c(t,"iter")&&(e.iter=t.iter,!g(e.iter))?new TypeError(f("1MB2t","iter",e.iter)):c(t,"dir")&&(e.dir=t.dir,1!==e.dir&&-1!==e.dir)?new TypeError(f("1MB2v","dir",e.dir)):null:new TypeError(f("1MB2V",t))}(o,n),a))throw a;return fr("Creating a readable stream configured with the following options: %s.",JSON.stringify(o)),lr.call(this,o),s(this,"_destroyed",!1),e(this,"_objectMode",o.objectMode),e(this,"_sep",o.sep),e(this,"_serialize",o.serialize||JSON.stringify),e(this,"_src",r),e(this,"_stride",o.dir),e(this,"_iter",o.iter),s(this,"_i",0),s(this,"_idx",1===o.dir?-1:r.length),this}function dr(e,t){var r;if(arguments.length>1){if(!l(r=t))throw new TypeError(f("1MB2V",r));r=i({},t)}else r={};return r.objectMode=!0,new cr(e,r)}function pr(e){var t;if(arguments.length){if(!l(e))throw new TypeError(f("1MB2V",e));t=i({},e)}else t={};return function(e){return new cr(e,t)}}o(cr,lr),e(cr.prototype,"_read",(function(){var e,t,r;if(!this._destroyed)for(e=!0;e;){if(t=null,this._i+=1,this._i>this._iter||0===this._src.length)return fr("Finished iteration."),this.push(null);this._idx+=this._stride,this._stride>0&&this._idx>=this._src.length?this._idx%=this._src.length:this._stride<0&&this._idx<0&&(this._idx+=this._src.length),r=this._src[this._idx],fr("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(r),this._idx,this._i),!1===this._objectMode&&("string"==typeof(r=this._serialize(r))?r=1===this._i?a(r):a(this._sep+r):n(r)?this._i>1&&(r=u.concat([a(this._sep),r])):t=new Error(f("1MBA9",r))),t?this.emit("error",t):e=this.push(r)}})),e(cr.prototype,"destroy",(function(e){var t;return this._destroyed?(fr("Attempted to destroy an already destroyed stream."),this):(t=this,this._destroyed=!0,h((function(){e&&(fr("Stream was destroyed due to an error. Error: %s.",r(e)?e.message:JSON.stringify(e)),t.emit("error",e));fr("Closing the stream..."),t.emit("close")})),this)})),e(cr,"objectMode",dr),e(cr,"factory",pr);export{cr as default,pr as factory,dr as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29b4469 --- /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-circular-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 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 nextTick from '@stdlib/utils-next-tick';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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._iter || this._src.length === 0 ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tthis._idx += this._stride;\n\t\tif ( this._stride > 0 && this._idx >= this._src.length ) {\n\t\t\tthis._idx %= this._src.length;\n\t\t} else if ( this._stride < 0 && this._idx < 0 ) {\n\t\t\tthis._idx += this._src.length;\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements.\n*\n* @constructor\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = new CircularArrayStream( arr, opts );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction CircularArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof CircularArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new CircularArrayStream( src, options );\n\t\t}\n\t\treturn new CircularArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( '1MB2O', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\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, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Cache the number of iterations:\n\tsetNonEnumerableReadOnly( this, '_iter', opts.iter );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( CircularArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof CircularArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {CircularArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nexport default CircularArrayStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir] - iteration direction\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( '1MB2V', 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( '1MB2W', '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( '1MB2o', '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( '1MB7n', '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( '1MB4k', '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( '1MB6p', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\topts.iter = options.iter;\n\t\tif ( !isNonNegativeInteger( opts.iter ) ) {\n\t\t\treturn new TypeError( format( '1MB2t', 'iter', opts.iter ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( '1MB2v', 'dir', opts.dir ) );\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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @param {Collection} src - source array-like object\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* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {CircularArrayStream} 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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = objectMode( arr, opts );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new CircularArrayStream( src, 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 CircularArrayStream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from circular array-like objects.\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* @param {integer} [options.iter=1e308] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\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 ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1MB2V', 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 a circular array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\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 {CircularArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new CircularArrayStream( src, 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 an array-like object which repeatedly iterates over a provided value's elements.\n*\n* @module @stdlib/streams-node-from-circular-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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream( arr, opts );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\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 circularArrayStream from '@stdlib/streams-node-from-circular-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 opts = {\n* 'iter': arr.length * 2\n* };\n*\n* var stream = circularArrayStream.objectMode( arr, opts );\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","CircularArrayStream","src","options","opts","err","this","arguments","length","isCollection","TypeError","format","assign","DEFAULTS","isObject","hasOwnProp","sep","isString","objectMode","isBoolean","encoding","highWaterMark","isNonNegative","serialize","isFunction","iter","isNonNegativeInteger","dir","validate","JSON","stringify","call","setNonEnumerable","setNonEnumerableReadOnly","factory","inherit","prototype","FLG","v","_destroyed","_i","_iter","_src","push","_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 e5d03c7..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-circular-array-stream' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 200d073..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "objectMode": false, - "encoding": null, - "sep": "\n", - "iter": 1e308, - "dir": 1 -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 79b247d..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating readable streams from circular array-like objects. -* -* @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 -* @param {integer} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @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 ) ); -* } -*/ -function factory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1MB2V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return createStream; - - /** - * Returns a readable stream from a circular array-like object. - * - * @private - * @param {Collection} src - source array-like object - * @throws {TypeError} must provide an array-like object - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {CircularArrayStream} Stream instance - */ - function createStream( src ) { - return new CircularArrayStream( src, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 5d3a135..0000000 --- a/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 an array-like object which repeatedly iterates over a provided value's elements. -* -* @module @stdlib/streams-node-from-circular-array -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 = circularArrayStream.factory( opts ); -* -* // Create 10 identically configured streams... -* var streams = []; -* for ( i = 0; i < 10; i++ ) { -* streams.push( createStream( arr ) ); -* } -* -* @example -* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-base-randu' ); -* var circularArrayStream = require( '@stdlib/streams-node-from-circular-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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = circularArrayStream.objectMode( arr, opts ); -* -* 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 2a6ea3a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,268 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 nextTick = require( '@stdlib/utils-next-tick' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -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._iter || this._src.length === 0 ) { - debug( 'Finished iteration.' ); - return this.push( null ); - } - this._idx += this._stride; - if ( this._stride > 0 && this._idx >= this._src.length ) { - this._idx %= this._src.length; - } else if ( this._stride < 0 && this._idx < 0 ) { - this._idx += this._src.length; - } - v = this._src[ this._idx ]; - debug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i ); - - 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( '1MBA9', 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 {CircularArrayStream} 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 which repeatedly iterates over a provided value's elements. -* -* @constructor -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = new CircularArrayStream( arr, opts ); -* -* stream.pipe( inspectStream( log ) ); -*/ -function CircularArrayStream( src, options ) { - var opts; - var err; - if ( !( this instanceof CircularArrayStream ) ) { - if ( arguments.length > 1 ) { - return new CircularArrayStream( src, options ); - } - return new CircularArrayStream( src ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( '1MB2O', src ) ); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - 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, '_src', src ); - - // Cache the array "stride": - setNonEnumerableReadOnly( this, '_stride', opts.dir ); - - // Cache the number of iterations: - setNonEnumerableReadOnly( this, '_iter', opts.iter ); - - // Initialize an iteration counter: - setNonEnumerable( this, '_i', 0 ); - - // Initialize the source index (pointer): - setNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? -1 : src.length ); - - return this; -} - -/* -* Inherit from the `Readable` prototype. -*/ -inherit( CircularArrayStream, Readable ); - -/** -* Implements the `_read` method. -* -* @private -* @name _read -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {number} size - number (of bytes) to read -* @returns {void} -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, '_read', read ); - -/** -* Gracefully destroys a stream, providing backward compatibility. -* -* @name destroy -* @memberof CircularArrayStream.prototype -* @type {Function} -* @param {(string|Object|Error)} [error] - error -* @returns {CircularArrayStream} Stream instance -*/ -setNonEnumerableReadOnly( CircularArrayStream.prototype, 'destroy', destroy ); - - -// EXPORTS // - -module.exports = CircularArrayStream; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 417c37f..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 CircularArrayStream = require( './main.js' ); - - -// MAIN // - -/** -* Returns an "objectMode" readable stream from an array-like object which repeatedly iterates over a provided value's elements. -* -* @param {Collection} src - source array-like object -* @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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {CircularArrayStream} 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 opts = { -* 'iter': arr.length * 2 -* }; -* -* var stream = objectMode( arr, opts ); -* -* stream.pipe( inspectStream.objectMode( log ) ); -*/ -function objectMode( src, options ) { - var opts; - if ( arguments.length > 1 ) { - opts = options; - if ( !isObject( opts ) ) { - throw new TypeError( format( '1MB2V', opts ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - opts.objectMode = true; - return new CircularArrayStream( src, opts ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 5bbc36f..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,112 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).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 -* @param {NonNegativeInteger} [options.iter=1e308] - number of iterations -* @param {integer} [options.dir] - iteration direction -* @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( '1MB2V', options ) ); - } - if ( hasOwnProp( options, 'sep' ) ) { - opts.sep = options.sep; - if ( !isString( opts.sep ) ) { - return new TypeError( format( '1MB2W', 'sep', opts.sep ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1MB2o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'encoding' ) ) { - opts.encoding = options.encoding; - if ( !isString( opts.encoding ) && opts.encoding !== null ) { - return new TypeError( format( '1MB7n', 'encoding', opts.encoding ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1MB4k', 'highWaterMark', opts.highWaterMark ) ); - } - } - if ( hasOwnProp( options, 'serialize' ) ) { - opts.serialize = options.serialize; - if ( !isFunction( opts.serialize ) ) { - return new TypeError( format( '1MB6p', 'serialize', opts.serialize ) ); - } - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( opts.iter ) ) { - return new TypeError( format( '1MB2t', 'iter', opts.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( opts.dir !== 1 && opts.dir !== -1 ) { - return new TypeError( format( '1MB2v', 'dir', opts.dir ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 2498a0c..32d7b75 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a readable stream from a circular 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.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-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..a6d9f2f --- /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 f0c592b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var CircularArrayStream = 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 an array-like 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 an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var createStream = factory(); - createStream( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if not provided an array-like object (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( 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( [ 1, 2, 3 ] ); - }; - } -}); - -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( [ 1, 2, 3 ] ); - }; - } -}); - -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 ) instanceof CircularArrayStream, 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 ) instanceof CircularArrayStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9a22765..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 circularArrayStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, '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 circularArrayStream.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 circularArrayStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index d19b6e2..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,850 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 circularArrayStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circularArrayStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( value ); - }; - } -}); - -tape( 'the function throws an error if not provided an array-like object for the first 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() { - circularArrayStream( 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() { - circularArrayStream( [ 1, 2, 3 ], 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() { - circularArrayStream( [ 1, 2, 3 ], { - 'objectMode': value - }); - }; - } -}); - -tape( 'the function is a constructor which returns a readable stream', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = new CircularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof Readable, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var CircularArrayStream = circularArrayStream; - var s; - - s = circularArrayStream( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a readable stream (no new)', function test( t ) { - var s = circularArrayStream( [ 1, 2, 3 ] ); - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 = circularArrayStream( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - - 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 "circular" array-like object (array)', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '\n', - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( parseFloat( result[ i ] ), values[ i%values.length ], 'returns expected value. i: ' + i + '.' ); - } - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" array-like object (object mode; array)', function test( t ) { - var iStream; - var values; - var opts; - var s; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, values[ i%values.length ], 'returns expected value. i: '+i+'.' ); - } - - function onEnd() { - t.pass( 'stream ended' ); - t.end(); - } -}); - -tape( 'the constructor returns a stream which streams elements of a "circular" 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 = circularArrayStream( arr, 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 "circular" 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 = circularArrayStream( arr, 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 supports specifying the iteration direction (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 = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'sep': '\n', - 'dir': -1, - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, '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 supports specifying the iteration direction (object mode; array)', function test( t ) { - var expected; - var iStream; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1 ]; - - opts = { - 'objectMode': true, - 'iter': values.length * 2, - 'dir': -1 - }; - s = circularArrayStream( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, expected[ i ], 'returns expected value. i: '+i+'.' ); - } - - 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 iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, values.length, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i ], 'returns expected value' ); - } - t.end(); - } -}); - -tape( 'the constructor supports providing a custom separator for streamed values', function test( t ) { - var iStream; - var result; - var values; - var opts; - var s; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - opts = { - 'sep': '--++--', - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseFloat( result[ i ] ); - t.equal( v, values[ i%values.length ], '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 opts; - var s; - - values = [ - { - 'value': 1 - }, - { - 'value': 2 - }, - { - 'value': 3 - }, - { - 'value': 4 - }, - { - 'value': 5 - }, - { - 'value': 6 - }, - { - 'value': 7 - }, - { - 'value': 8 - } - ]; - - opts = { - 'iter': values.length * 2 - }; - s = circularArrayStream( values, 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( '\n' ); - t.equal( result.length, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - v = parseJSON( result[ i ] ); - t.deepEqual( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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, opts.iter, 'has expected length' ); - for ( i = 0; i < result.length; i++ ) { - t.equal( result[ i ], expected[ i%expected.length ], '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, - 'iter': values.length - }; - s = circularArrayStream( values, 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 opts; - var FLG; - var s; - - values = [ 1, 2, 3, void 0, 5, 6, 7, 8 ]; - - opts = { - 'iter': values.length - }; - s = circularArrayStream( values, opts ); - 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 64543e8..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 CircularArrayStream = 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 an array-like object as a first 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( 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( [ 1, 2, 3 ], 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( [ 1, 2, 3 ], { - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var s = objectMode( [ 1, 2, 3 ] ); - t.equal( s instanceof CircularArrayStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream instance (options)', function test( t ) { - var s = objectMode( [ 1, 2, 3 ], {} ); - t.equal( s instanceof CircularArrayStream, 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 ]; - - opts = { - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], '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, - 'iter': values.length * 3 - }; - s = objectMode( values, opts ); - s.on( 'end', onEnd ); - - opts = { - 'objectMode': true - }; - iStream = inspectStream( opts, inspect ); - - s.pipe( iStream ); - - function inspect( v, i ) { - t.equal( v, values[ i%values.length ], 'returns expected value' ); - } - - function onEnd() { - t.end(); - } -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 654df63..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,302 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 an error if provided an `iter` option which is not a nonnegative integer', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'iter': 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 `dir` option which is neither `1` nor `-1`', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - 3.14, - 0, - NaN, - true, - false, - void 0, - null, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dir': 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, - 'iter': 1, - 'dir': 1 - }; - 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, - 'iter': 10, - 'dir': -1 - }; - 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(); -});